# Set the Width of the Column Based on the Content

## Environment

<table>
	<tbody>
		<tr>
			<td>Product Version</td>
			<td>3.0.0</td>
		</tr>
		<tr>
			<td>Product</td>
			<td>Progress® KendoReact Grid</td>
		</tr>
	</tbody>
</table>

## Description

How can I set the width of the Grid column based on the content. I want the column width to be set based on the longest value in the column.

## Solution

### Using HTML canvas measureText()

In order to automatically calculate the column width, we can suggest using the Canvas API [measureText](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText) function that can calculate the text width based on the font weight, size, and family. Then we can use that information to dynamically set the width of the column.

[Demo Source](https://demos.telerik.com/kendo-react-ui/knowledge-base/grid/auto-width/canvas/source.txt)

### Using calculate-size

Another approach would be to use a package called [calculate-size](https://www.npmjs.com/package/calculate-size) or similar which will calculate the size of the text based on the font.

[Demo Source](https://demos.telerik.com/kendo-react-ui/knowledge-base/grid/auto-width/calculate-size/source.txt)
