Skip to content
SENVENLI UI

Table

Records people scan, compare, sort and act on: sortable columns, row selection by checkbox, a row that opens its record.
Orders
import { Table } from "@senvenli/react/collection";

Examples

Row selection

A checkbox per row and one in the header for the whole table.

Sortable columns

The table reports the sort; you sort the rows, here or on the server.

Guidelines

When to use it

  • Records with several comparable fields on screens 640px and wider.

Use something else when

  • The table also needs search, filters, paging or a column picker. Data table
  • The screen is narrow or each record is one line of text. Grid list

Accessibility

Keyboard

KeysWhat happens
Arrow keysMove between cells and rows.
SpaceSelects the focused row.
EnterOpens the focused row's record.

Built in

  • The row header column names each row for screen readers.
  • Sort state is announced on the column header.

You provide

  • An aria-label for the table.

API reference

Table

aria-labelRequired
string

Names the table ("Orders").

columnsRequired
readonly TableColumn<T>[]
rowsRequired
readonly T[]
rowKey
(row: T) => Key

The row's stable id; row.id by default. Ids must be unique within the table. When the data has no single unique field, build one from the fields that are (${row.date}:${row.channel}), or add the row's index as a last resort. A repeated id still renders every row: the first keeps its id and the later ones are keyed a#2, a#3, … in row order, and selection and onRowAction receive those suffixed keys; a development warning names the repeated ids. A suffixed key follows the row's position, not the row: after a sort or filter, a selection made through it can move to another copy of the id.

selectionMode
"none" | "single" | "multiple"
selectedKeys
"all" | Iterable<Key>
defaultSelectedKeys
"all" | Iterable<Key>
onSelectionChange
(keys: Selection) => void
sortDescriptor
SortDescriptor
onSortChange
(descriptor: SortDescriptor) => void
density
Density

compact (36px rows) for dense working screens; default (48px) for public and content pages.

emptyState
React.ReactNode

Shown when there are no rows: an EmptyState, or one sentence on why it is empty and the action that fills it.

onRowAction
(key: Key) => void

Opens the record: the whole row is the target.

maxHeight
string

A height for the scroll area: the header stays put and gets a shadow once rows scroll under it.