Data Table
A table with filtering, sorting, row selection and row actions, composed from Table, Checkbox, Input Group and Dropdown Menu.
When to use
- A list users filter, sort, select from and act on: sources, API keys, records.
- Bulk actions on several rows at once, such as archiving sources.
When not to use
- Read-only data with no actions: use Table.
- A short list of rich items: use Item.
- Nothing to show yet: use Empty in place of the whole table, with the next action.
Install
npx shadcn@latest add @clinia/table @clinia/checkbox @clinia/input-group @clinia/dropdown-menu @clinia/badge @clinia/button| Status | Actions | ||
|---|---|---|---|
| Esther Howard | Pending | ||
| Floyd Miles | Inactive | ||
| Jane Cooper | Active | ||
| Ronald Richards | Active |
1 of 4 selected
Clinia rules
- Set
interactiveon every row: users select and act on them, so each row takes the hover tint. - Row actions live in one Dropdown Menu at the end of the row, behind a
ghosticon-smButton. Don't line up several buttons in every row. - Destructive actions sit last in the menu, after a separator, with
variant="destructive". - A filter that matches nothing keeps the table and says so in one row:
No patients match “cardio”. - Status columns use Badge with the status in words, never a coloured dot alone.
- Show how many rows are selected (
1 of 4 selected), next to the bulk actions when the table has them.
Do and don't
| Lab results | Synced | |
| Imaging | Synced |
| Lab results | |
| Imaging |
| No patients match “cardio”. |
| Name | Status |
|---|---|
Accessibility
Built in
- Every row checkbox and action button carries an
aria-labelnaming the row, since the visible cell text is not its label. - A selected row is tinted
bg-accent/15; the checked checkbox is the state cue that clears 3:1.
Your responsibility
- Set
aria-sort(ascendingordescending) on theTableHeadof the sorted column, and put the sort control in a real Button. - Set
indeterminateon the select-all Checkbox when only some rows are selected. - Announce the result count when a filter changes the rows, for example with a
role="status"region:3 patients.
How to test
- Tab to the filter and type: the rows update, and a screen reader hears the new count if you added a status region.
- Tab to a row checkbox and press Space: it toggles, the row tints and the selected count updates. A screen reader announces
Select Jane Cooper, checkbox, checked. - Tab to a row's actions button: it's announced with the row name. Press Enter: the menu opens. Arrow keys move, Escape closes it and focus returns to the button.
- Press the sort button in the header: the order flips, and a screen reader reads the column as sorted.