Preserve cells alignment after adding virtualization to shadcn data table.
I am using shadcn data table and trying to implement virtualization, but as soon as I add virtualization to it the cell alignment breaks and everything adopts randow width. Is there a way to preserve the default cell styling?
I have attached related photos. Thanks in advance.





1 Reply
solid-orange•11mo ago
To fix the height, you need to pass
ref={virtualizer.measureElement
; to fix the width, you need to set a width
on each cell. Absolutely positioned table rows can't rely on the table to inform its width, so you need to provide it yourself.