Documentation
Concepts

State attributes

Every state a part has is a data attribute or ARIA, present or absent, so any styling solution can read it.

A part's state is on its element, as data-* attributes and ARIA. A boolean attribute is present (empty) or absent, never "false".

Parts

Every part carries data-grid-part: root, grid, header, header-row, header-cell, body, row, cell, row-detail, empty, or summary, summary-row and summary-cell (Summary rows), column-resizer on a resize handle you render with useColumnResizer (Column resizing), group-label on a group's label you render with useGroupLabel (Collapsible groups and sticky labels), and row-drag-handle on a row's handle you render with /row-reorder's useRowDragHandle (Row reordering), and group-toggle on a group row's toggle you render with /row-grouping's useGroupToggle (Row grouping), and fill-handle on a fill handle you render with /fill's useFillHandle (Fill handle). Rows and cells carry their indexes: data-row-index (header rows are -1 and above, a header cell spanning rows is at its top one; the top summary rows are before the header's, the bottom ones after the body's) and data-column-index (a header cell spanning columns is at its first). Tests select by them, never by class names.

States

attributeonwhen
data-activecell, header cellit is the active cell
data-activerow, summary rowit holds the active cell
data-summarysummary, summary row, summary celltop or bottom: where its summary rows stay (Summary rows)
data-interactingcell, header cellits controls have the keys (Controls in cells)
data-editingcellit is being edited: it shows its editor (Editing)
data-fill-targetcella fill's drag would fill it (Fill handle)
data-fillingfill handlea drag on it is filling
data-loadingrow, cellits row is not loaded yet (getRow answered undefined)
data-emptyroot, gridthe grid has no rows (Empty state)
data-groupheader cellit is a group's (Column groups)
data-collapsibleheader cellit is a collapsible group's, with columnGroupCollapse() (Collapsible groups)
data-collapsedheader cellits collapsible group is closed
data-expandedrowit shows its detail (Master-detail)
data-group-rowrowit is a group row (Row grouping)
data-group-expandedrowit heads an expanded row group
data-depthrowits depth in the tree, 0 at the top, while the rows have kinds (getRowMeta)
data-expandedgroup toggleits row's group is expanded
data-selectedrowit is selected (Row selection)
data-selected-cellcellit is in the selected range (Cell selection)
data-range-edgecellthe range's edges it sits on, space-separated: top, bottom, start, end (match one with ~=)
data-pinnedcell, header cellstart or end: where its column is pinned, with columnPinning() (Pinned columns)
data-pinned-edgecell, header cellits pinned part's edge: it ends at the last column pinned at the start, or starts at the first pinned at the end
data-sortableheader cellits column is sortable, with sorting() installed (Sorting)
data-sortheader cellascending or descending, while its column is sorted
data-sort-priorityheader cellits column's place in the sort, 1-based
data-resizableheader cellits column can be resized, or for a group one of its columns, with columnResize() (Column resizing)
data-resizingheader cell, resize handlea drag is resizing its column (or group)
data-reorderableheader cellits column or group can be moved, with columnReorder() (Column reordering)
data-draggingheader cella drag is moving its column or group
data-drop-targetheader cellbefore or after: a drag would drop beside it, on that side
data-draggingrow, row drag handlea drag is moving the row (Row reordering)
data-drop-targetrowbefore or after: a row's drag would drop beside it, on that side
data-reorderablerow drag handlea press on it drags its row (the rows move, the grid is not sorted, the row is loaded)

ARIA

attributeonvalue
rolegrid, rowgroup, row, columnheader, gridcellthe grid pattern; treegrid on the grid while the rows have kinds (Row grouping)
aria-levelrowits depth + 1, in a treegrid
aria-expandedrow, group togglewhether a group row (or a row that expands) shows its rows
aria-setsize, aria-posinsetrowits siblings' count and its place among them, from 1, when its meta says
aria-rowcountgridevery row, header and summary rows included, rendered or not
aria-colcountgridevery column
aria-rowindexrow, summary row1-based, as they show: the header rows, the top summary rows, the body rows, the bottom summary rows
aria-colindexcell, header cell1-based (a group's first column)
aria-colspancell, header cell, row detailthe columns a group or a spanning cell covers, when more than one; a detail spans every column
aria-rowspanheader cellthe header rows a column spans, when more than one
aria-sortheader cellthe first sorted column's direction, with sorting() installed
aria-multiselectablegridtrue when many rows can be selected, or ranges of cells
aria-selectedrowtrue or false on a row that can be selected, true on one your keys select anyway (false is ARIA's own "selectable, not selected"); a group row's, true while every one of its rows is
aria-selectedcelltrue in the selected range, false outside it, while cells are selectable (Cell selection); none on header and summary cells
roleresize handleseparator, with aria-orientation="vertical"; its name (aria-label) is yours
aria-valuenowresize handleits column's width on screen in pixels (a group's: its columns')
aria-valuemin, aria-valuemaxresize handlethe narrowest and widest it resizes to; without a maximum, the view's width (at least the width)

Styling a state

grid.css
[data-grid-part="cell"][data-active] {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

[data-grid-part="row"][data-loading] [data-grid-part="cell"]::after {
    content: "";
    inline-size: 60%;
    block-size: 0.75rem;
    background: var(--placeholder);
}

With Tailwind: data-active:outline-2, data-loading:opacity-50, in-data-empty:hidden, data-group:justify-center.