Basic column resizing
Pass withColumnResizing to useDataGrid to let users resize columns by dragging
column boundaries. Set the initial column width with the size property of a column definition:
Resize handles
Set withLastColumnResizing on DataGrid to add a resize handle to the last column.
Double-click a handle to fit the column width to its content.
To resize columns from your code, pass the table and grid element to autosizeColumns:
Resize mode
Set columnResizeMode to change when column widths are updated:
onEnd(default) – when the user releases the handle, a guide line previews the new width while draggingonChange– while the user drags the handle
Column size constraints
Use minSize and maxSize in column definitions to limit the width of a resized column:
Controlled column sizing
Pass columnSizing and onColumnSizingChange to useDataGrid for controlled column sizing state:
Current column sizing state:
{}Disable resizing per column
Set enableResizing: false on a column definition to disable resizing of that column:
Utility columns and actions columns cannot be resized by the user. Their width depends on
the grid size, use columnSizing to override it.
Column size defaults
TanStack Table uses these defaults when size, minSize or maxSize are not set:
Override them with tableOptions.defaultColumn:
Table layout
By default, columns use their configured width and the last column fills the remaining space.
Set tableLayout="auto" to let the browser distribute column widths based on content.
Use textOverflow="wrap" to wrap text that does not fit:
Header groups
Group headers have resize handles too: dragging resizes all columns of the group proportionally, double-click autosizes them:
RTL support
The resize direction is taken from the closest DirectionProvider. Set columnResizeDirection
to override it: