هذه الصفحة غير مترجمة بعد، وهي معروضة بالإنجليزية.

The data table sorts when you click a column header and selects rows with a checkbox column. Sorting is on by default; pass enableRowSelection to add the checkboxes, and selection with onSelectionChange to read the selected rows.

Status
Lena ParkEngineerPlatformActive
Omar HaddadDesignerProductActive
Sofia ReyesEngineerPaymentsAway
Yuki TanakaManagerPlatformActive
Amir NasserAnalystGrowthActive
Chloe MartinEngineerPaymentsOn leave

Not sorted.

No rows selected.

Click a header to sort it ascending; click again for descending, and a third time to clear. Shift-click a second header to add it to the sort. Tick rows to select them: the text under the table lists them. Chloe Martin is on leave, so her checkbox is disabled.

Sorting

Every data column, one with an accessorKey or accessorFn, sorts unless its definition sets enableSorting: false, as the Status column does. A display column, such as one that only holds buttons, has no value to sort by and never sorts. The header holds a button, and its <th> carries aria-sort, so screen readers announce the order.

  • sorting and onSortingChange control the sort. The state is a list of { id, desc }, one per sorted column, in priority order. Leave them out and use defaultSorting for a starting sort the table keeps itself.
  • enableMultiSort lets shift-click add columns to the sort.
  • Each column sorts ascending first. Set sortDescFirst: true in a column definition to start that column descending, as you might for numbers and dates.
  • manualSorting says the rows arrive already sorted, for sorting on the server; the table then only reports the clicks. The server data guide sorts this way.

The header button and the arrow are the SortTrigger and SortIcon slots, so a design system’s own can replace them.

Selection

enableRowSelection adds a checkbox to each row and a select-all checkbox to the header. Given a function, it decides per row: here, rows whose status is “On leave” cannot be selected.

  • selection and onSelectionChange control the selection as row objects, matched to rows by getRowId. defaultSelection sets a starting selection instead.
  • The header checkbox selects every selectable row on the current page, and is indeterminate while only some are selected.
  • resetSelectionOnPageChange clears the selection when the page or the page size changes.

Give rows a stable id with getRowId, so a selection survives re-sorting and new data. The checkboxes are the Checkbox slot, named by the selectRow and selectAll labels.