Ravox KitData
Data Table
You declare the columns and it sorts, searches (accent-insensitive), paginates, selects rows with bulk actions and shows/hides columns. Empty, no-results and loading states are ready. No table library.
1–5 of 23
Page 1 of 5
Settings
Toggles
Examples
Controlled selection
1 pedido na próxima remessa · 6 itens
1 selected
1–5 of 20
Page 1 of 4
Updating without jumping
1–4 of 8
Page 1 of 2
Scrolling with a sticky header
Installation
The command creates components/ui/data-table.tsx in your project and installs the theme with it. The file is yours: edit it as you like.
npx @ravox-ui/cli add data-tableProps
| Prop | Type | Default | Description |
|---|---|---|---|
| data | T[] | — | The rows. They stay on the client: for thousands of records, paginate on the server and pass only the page. |
| columns | DataTableColumn<T>[] | — | { key, title, value?, cell?, numeric?, sortable?, searchable?, hideable?, hidden?, width? }. value is for sorting and searching; cell is for rendering. |
| rowKey | (row: T) => string | — | Unique id of each row (selection and key). |
| label | string | — | Table name: becomes the caption for screen readers and the name of the search and pagination. |
| search | boolean | true | Search field over the text columns (or the ones marked searchable). Esc clears it. |
| pageSize | number | 10 | Rows per page. 0 turns pagination off. |
| pageSizeOptions | number[] | [10, 25, 50] | Options for "Rows per page". With only one, the selector disappears. |
| selectable | boolean | false | Checkbox column. The header one selects the page and offers to select all results. |
| selected / onSelectionChange | string[] / (ids: string[]) => void | — | Controlled selection (rowKey ids). Without selected, it keeps the selection itself. |
| bulkActions | (selected: T[], clear: () => void) => ReactNode | — | Buttons in the bar that appears when rows are selected. |
| initialSort | { key, direction: "asc" | "desc" } | null | — | Initial order. Clicking the title cycles through ascending, descending and no order; aria-sort follows. |
| columnMenu | boolean | true | "Columns" button to hide and show columns (the last visible one can't be hidden). |
| loading | boolean | false | Without data: skeleton rows. With data: keeps the previous screen dimmed, without jumping. |
| empty | ReactNode | — | What appears when data comes in empty. A search with no results has its own message with "Clear search". |
| extra | ReactNode | — | Something on the right of the bar (e.g. a "New customer" button). |
| density | "compact" | "normal" | "relaxed" | "normal" | Passed on to Table. |
| maxHeight | number | string | — | With it, the body scrolls and the header sticks to the top. |