Skip to content

Grid DOM state contract

View as Markdown

@sapporta/grid/index.css and public DOM state attributes. GridCore renders grid mechanics and stable DOM state. It does not own product visuals. Style rows, cells, nested levels, and editing state with data-grid-part, data-row-*, and data-cell-* selectors.

This page enumerates the stable DOM attributes application CSS may target. For complete selectors and styling recipes, use the Styling guide.

<div
data-grid-part="row"
data-row-kind="data"
data-row-active="true"
data-row-selected="true"
data-row-interaction-status="cursor-selected"
data-row-selectable="true"
aria-selected="true"
/>
AttributeMeaning
data-grid-part="row"Identifies a body row.
data-row-kindRow kind, such as data or phantom.
data-row-active="true"This row is the current row.
data-row-selected="true"This row is in the effective row selection.
data-row-interaction-statusCombined row cursor and row selection status.
data-row-selectableWhether row-operation selection can target this row.
aria-selected="true"Present when the row is selected.

Prefer data-row-active and data-row-selected for styling. Use data-row-interaction-status only when one combined status value is genuinely more convenient.

Rows of a tree level carry their position in the tree:

AttributeMeaning
data-tree-depthDepth in the tree, with top-level rows at 0.
data-tree-context="true"The row is present only because a descendant matched the source’s filter.
aria-levelDepth plus one.
aria-expandedWhether the row is expanded; present only on rows with children.
aria-setsizeNumber of siblings, including the row.
aria-posinsetOne-based position among its siblings.
<div
role="gridcell"
data-grid-part="cell"
data-cell-status="focus"
data-col-id="name"
/>
AttributeMeaning
data-grid-part="cell"Identifies a body cell.
data-cell-status="focus"The active cell.
data-cell-status="in-selection"A cell in the selected range.
data-cell-status="editing"A cell with an open editor.
data-col-idColumn id.
<div
data-grid-part="root"
data-grid-path="projects"
data-grid-depth="0"
data-active="true"
/>
AttributeMeaning
data-grid-part="root"Identifies a grid level root.
data-grid-pathStable logical path for this level.
data-grid-depthNesting depth, with root at 0.
data-activeWhether this level owns the active cursor.

Inside cells and levels, data-grid-part names the parts application CSS can target:

PartElement
expand-cellA cell that holds a child-level expansion control.
expand-chevronThe expand or collapse button of a row that can expand.
expand-placeholderThe chevron’s space on a row that cannot expand, such as a footer, subtotal, opening, or closing row.
expand-contentThe cell content beside the chevron or placeholder.
tree-cellThe tree column’s frame, indented by the row’s depth.
tree-chevronThe expand or collapse button of a tree row with children.
tree-placeholderThe chevron’s space on a tree row without children.
tree-contentThe cell content beside the chevron or placeholder.
text-cellThe value of a ColumnPreset text cell.
selection-summaryThe row that shows a sum under each selected numeric column.
selection-summary-contentOne column’s summary.
selection-summary-label, selection-summary-valueThe summary’s label (Sum) and its value.
level-status, level-status-textA level’s loading or error band and its message.
level-emptyThe empty state of a level with no rows.

expand-placeholder keeps the chevron’s width, so cell content lines up across rows that can and cannot expand. tree-placeholder does the same in a tree column. tree-cell also carries data-tree-depth, and on a row that can expand data-expandable="true" and data-expanded.

When multiple rules can apply, order application CSS from broad to specific:

  1. base row and phantom row
  2. hover row
  3. selected row
  4. active row
  5. active + selected row
  6. cell range
  7. active cell
  8. editing cell

The Sapporta preset follows the same visual order with low-specificity selectors, so normal application selectors such as .projectGrid [data-grid-part="row"][data-row-active="true"] override it.