Components
Data Table
A table with sorting, a text filter, faceted filters, row selection, column visibility, row actions and pages, drawn like Table.
Data Table
| Ombelle | Stable | |
| Papier | Stable | |
| Cristal | Experimental |
0 of 3 row(s) selected.
Page 1 of 1
Installation
Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.
pnpm dlx @ombelle-ui/cli@1.1.2 add data-tableAdds components/ui/data-table.tsx and installs react, @radix-ui/react-dropdown-menu, @radix-ui/react-popover, @tanstack/react-table, clsx, tailwind-merge, lucide-react with lifecycle scripts disabled. This is a client component.
In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.
Usage
import { DataTable, DataTableRowAction, DataTableRowActions, actionsColumn, dataTableColumns, selectColumn, type DataTableColumn } from '@/components/ui/data-table'
type Preset = { name: string; family: string; status: 'Stable' | 'Accessibility caveat'; components: number }
const presets: Preset[] = [{ name: 'Ombelle', family: 'Ombelle', status: 'Stable', components: 63 }, { name: 'Cristal', family: 'Liquid glass', status: 'Accessibility caveat', components: 63 }, { name: 'Papier', family: 'Papier', status: 'Stable', components: 63 }]
const column = dataTableColumns<Preset>()
const columns: DataTableColumn<Preset>[] = [selectColumn(), column.accessor('name', { header: 'Preset' }), column.accessor('family', { header: 'Family' }), column.accessor('status', { header: 'Status' }), column.accessor('components', { header: 'Components' }), actionsColumn(row => <DataTableRowActions><DataTableRowAction onSelect={() => console.log('open', row.original.name)}>Open</DataTableRowAction><DataTableRowAction variant="destructive">Delete</DataTableRowAction></DataTableRowActions>)]
export function Example(){return <DataTable aria-label="Presets" columns={columns} data={presets} filterColumn="name" filterLabel="Filter presets" facets={[{ column: 'status', title: 'Status' }]} columnVisibility pagination pageSize={10} />}API and states
- API
- DataTable (columns, data, state and on…Change, selectable, filterColumn, filterLabel, facets, columnVisibility, pagination, pageSize, toolbar, emptyLabel, caption), DataTableColumnHeader, DataTableToolbar, DataTableFilter, DataTableFacetedFilter, DataTableViewOptions, DataTablePagination, DataTableRowActions, DataTableRowAction, selectColumn, actionsColumn, dataTableColumns, useDataTable
- Minimum states
- Default, sorted ascending and descending, filtered, no results, rows selected, columns hidden, first and last page
- Native basis
- TanStack Table with reviewed Radix Dropdown Menu and Popover; Base UI Menu and Popover in the Base UI edition
- Styles
- Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.