Table
Rows separated by a hairline, a header that is not a toolbar, and a hover state you can find at any width.
Loading documentation…
Three decisions do most of the work in this component.
DataTable is this component with all of it wired
up. Compose Table by hand when the list is simple, or when the behaviour is
yours.
primary marks the row's headline — the id, the name, the thing you scan for.
It gets full contrast and medium weight so everything else can stay quiet.
numeric switches to tabular figures and right alignment, which is what makes
a column of numbers comparable at a glance.
onSort turns a header into a button; sort says which way it is pointing.
false means "sortable, but not currently sorted".
Table.SelectHeader and Table.SelectCell are the narrow first column for
checkboxes; useSelection computes the header's indeterminate
state. Table.ActionCell is the trailing column: it fades its contents in on
hover, so fifty rows are not fifty buttons competing with the data — but keeps
them visible whenever the keyboard is inside the cell.
stickyHeader pins the header while the body scrolls. It needs a bounded
maxHeight — there is nothing to scroll inside otherwise.
Tints every other row. Helps when scanning wide, numeric tables.
Highlights rows on hover. Only useful when rows are clickable.
Pins the header. Needs a bounded maxHeight.
Caps the scroll container, for example "24rem".
Class for the scroll container around the <table>.
Tints the row and exposes data-selected, so the whole row reflects its
checkbox instead of leaving a lone tick to carry the state.
Logical alignment. It shadows the deprecated HTML align attribute on
purpose.
Makes the header a sort button.
The current sort for this column. false means sortable but not sorted.
Logical alignment.
Tabular figures, right-aligned — for anything counted or measured.
The row's headline. Full contrast, medium weight.
The semantic sections: <thead>, <tbody>, <caption>.
The narrow first column that holds a checkbox.
The trailing column for row actions, revealed on hover or keyboard focus.