What is a cleaner way to set table cell's width property to auto? #238
Unanswered
dnjsgur0629
asked this question in
Q&A
Replies: 1 comment
-
I got better results by specifying only size of the pinned columns and setting the size of the remaining columns to 1 (a value smaller than theirs content). export const mockColumns = [
{
accessorKey: "name",
header: "NAME",
minSize: 200,
size: 200,
},
{
accessorKey: "firstName",
header: "FIRST NAME",
minSize: 180,
size: 180,
},
{
accessorKey: "middleName",
header: "MIDDLE NAME",
size: 1
},
{
accessorKey: "lastName",
header: "LAST NAME",
size: 1
},
{
accessorKey: "salary",
header: "SALARY",
size: 1
},
{
accessorKey: "total",
header: "TOTAL",
size: 1
}
]; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted the width of each column to fit the content not fixed width
By wrapping
MaterialReactTable
with aBox
withmax-width: max-content
and settingTableCell's width
toauto !important
viaThemProvider
And I got this:

I don't think this is the best way.
Also, this way caused the table to be act up when using the column pinning feature.
From the description here, I understood that setting width to auto is not possible in general way.
Is my understanding correct? And is there a cleaner way to achieve what I want?
Beta Was this translation helpful? Give feedback.
All reactions