T
TanStack3y ago
vicious-gold

Custom column width for each column

Hello everyone! I would like to know how can i define a different width for each column as default. I know the default is 150px and i can only change the size for all columns at once, during the headers map. I tried to do it dynamically using the column ID, but it doesnt work, it keeps changing the size of all columns.
7 Replies
fair-rose
fair-rose3y ago
hey im facing the same problem, i saw that in the typing for the column there is minSize,maxSize and size, but even tho i apply the width after on the td ot th, the tables ignore it
vicious-gold
vicious-goldOP3y ago
yes, the table ignores it and when you set the column size, minSize and maxSize in columnDef, it still ignores it, although it shows the size in the column's object
fair-rose
fair-rose3y ago
I've tried also the answer provided on stack overflow with the defaultColumn width, no chance
vicious-gold
vicious-goldOP3y ago
i didnt try that, but nothing worked for me
rival-black
rival-black3y ago
I am curious as well, it seems to be a basic functionnality. Weird that it is so hard to find it!
exotic-emerald
exotic-emerald3y ago
have anyone found this ?, i tried to work it with last: [tailwind] but doesnt seem to happen, btw how can we style the headers(individually)
fair-rose
fair-rose3y ago
It's a headless solution, meaning it might calculate the preferred width but ultimately it's up to you to actually apply said width to the DOM elements. While rendering the td tags you can access the calculated size as cell.column.getSize(), use that to set the td tags size through your preferred solution (I personally use style for this specifically due to its dynamic nature)

Did you find this page helpful?