Documentation
Getting started

Sizing the grid

The root is the scroll container and needs a size; rows and columns take theirs in pixels, from numbers or from a function.

The root is the scroll container

DataGrid.Root renders the element that scrolls (overflow: auto). The grid inside it is as large as the dataset, so the root needs a bounded size, from a fixed height, a flex or grid parent, or anything else your layout uses. The engine measures it with a ResizeObserver and follows it as it changes.

layout.tsx
<div className="flex h-dvh flex-col">
    <header>…</header>
    <DataGrid.Root className="min-h-0 flex-1" columns={columns} rows={rows}>
        …
    </DataGrid.Root>
</div>

Rows

rowHeight is a number (every row the same, the default 35) or a function of the row's index. A function is summed once into offsets, so positions stay exact at any scroll position. See the variable-row-height example.

rowHeight="auto" makes each row as tall as its content: the grid measures the rows as they render, counting the others at estimatedRowHeight (35 by default) until then. The cells set the height, so let their text wrap, and their padding counts. See Measured heights and the auto-row-heights example.

A function's identity is its version

A new rowHeight function means new sizes: every offset is computed again. Define it outside the component or memoise it (useCallback), and pass a new one only when heights change.

headerRowHeight is a header row's height (35 by default): with column groups, the header is that times its rows. 0 renders no header.

Columns

A column's width is in pixels. The grid's width is the sum of its columns: wider than the root, it scrolls sideways, and columns are virtualized like rows. A resizable column starts at its width, and a person can resize it within its limits.

The grid can size columns itself (Automatic widths): a flex column takes its part of the width the others leave in the root, following the root as it changes, and an autoSize column fits its content once it renders. A column's width on screen is the width a person set, else its automatic width, else its flex share, else its width.