Column Resizing Feature Guide
Mantine React Table lets you easily change the default widths (sizes) of columns and has a built-in column resizing draggable handle feature.
Relevant Table Options
# | Prop Name | Type | Default Value | More Info Links | |
---|---|---|---|---|---|
1 | MRT Column Resizing Docs | ||||
2 | TanStack Table Core Table Docs | ||||
3 | MRT Column Resizing Docs | ||||
4 | TODO | ||||
5 | TanStack Table Column Sizing Docs | ||||
6 | TanStack Table Column Sizing Docs | ||||
Relevant Column Options
Relevant State
# | State Option | Type | Default Value | More Info Links | |
---|---|---|---|---|---|
1 | TanStack Table Column Sizing Docs | ||||
2 | TanStack Table Column Sizing Docs | ||||
Change Default Column Widths
Column Size
This was also covered in the Data Columns Guide, but we'll cover it again here.
You can change the width of any column by setting its
size
option on the column definition. minSize
and maxSize
are also available to enforce limits during resizing.You may notice, however, that the column sizes might not change as much as you would expect. This is because the browser treats
<th>
and <td>
elements differently with in a <table>
element by default.You can improve this slightly by changing the table layout to
fixed
instead of the default auto
in the mantineTableProps
.The columns will still try to increase their width to take up the full width of the table, but the columns that do have a defined size will have their width respected more.
For further reading on how table-layout
fixed
vs auto
works, we recommend reading this blog post by CSS-Tricks.If you are using either virtualization features or have the layoutMode set to
"grid"
, another option is to turn off flex grow for both the table head and body cells. You can see this down below at the bottom of this pageDefault Column
By default, columns will have the following size properties defined:
You can modify the default column widths by setting the
defaultColumn
table option.Enable Column Resizing Feature
enableColumnResizing
is the boolean table option that enables the column resizing feature.You can disable specific columns from being resizable by setting the
enableResizing
column option to false in their respective column definition.When Column Resizing is enabled, a CSStable-layout: fixed
style is automatically added to the<table>
element in order to make the browser respect the widths of the columns more. (Unless layoutMode is set to"grid"
)
Column Resize Mode
The default
columnResizeMode
is onChange
, which means that column resizing will occur immediately as the user drags the column resize handle. If you are running into performance issues because of many other enabled features, you might want to set the columnResizeMode
to onEnd
instead. This will make the column resizing only occur after the user has finished dragging the column resize handle and released their mouse.First Name | Last Name | Email Address | City | Country |
---|---|---|---|---|
Dylan | Murray | dmurray@yopmail.com | East Daphne | USA |
Raquel | Kohler | rkholer33@yopmail.com | Columbus | USA |
Ervin | Reinger | ereinger@mailinator.com | Toronto | Canada |
Brittany | McCullough | bmccullough44@mailinator.com | Lincoln | USA |
Branson | Frami | bframi@yopmain.com | New York | USA |
1-5 of 5
Disable Column Growing
If you want to prevent the columns from growing to fill the width of the table, use this flexbox trick when the layoutMode is
"grid"
:First Name | Last Name | Email Address |
---|---|---|
Dylan | Murray | dmurray@yopmail.com |
Raquel | Kohler | rkholer33@yopmail.com |
Ervin | Reinger | ereinger@mailinator.com |
Brittany | McCullough | bmccullough44@mailinator.com |
Branson | Frami | bframi@yopmain.com |
1-5 of 5
View Extra Storybook Examples