PatternAvailable
Data Table
A client-side table with search, sorting, pagination, and empty results.
Installation
Add the component and its dependencies from the registry running on your computer.
terminal
npx shadcn@latest add https://brutallab.facilito.dev/r/data-table.jsonUsage
Import the component into your project and keep the source code under your control.
tsx
'use client';
import { DataTable } from '@/components/ui/data-table';
export default function Demo() {
const rows = [
{ name: 'Atlas', status: 'Active', count: 12 },
{ name: 'Bloom', status: 'Draft', count: 4 },
{ name: 'Cedar', status: 'Active', count: 18 },
{ name: 'Delta', status: 'Active', count: 7 },
{ name: 'Echo', status: 'Draft', count: 2 },
];
return (
<DataTable
data={rows}
columns={[
{
id: 'name',
header: 'Name',
value: (row) => row.name,
sortable: true,
},
{ id: 'status', header: 'Status', value: (row) => row.status },
{
id: 'count',
header: 'Components',
value: (row) => row.count,
sortable: true,
},
]}
getRowId={(row) => row.name}
caption="Workspace component usage"
pageSize={3}
/>
);
}
States & interaction
Appearance, behavior and keyboard checks.
- The composition inherits its controls’ states. Test empty, content, loading and error cases where the application needs them.
- Examples on this page are runnable; the displayed code uses the same components. Business logic belongs to the consumer.
- Test the example with Tab and Shift+Tab. Focus must stay visible in both themes.
API Reference
BrutalLab-specific properties. Native attributes are supported as well.
| Prop | Type | Default | Description |
|---|---|---|---|
| data | T[] | — | Rows processed locally. |
| columns | DataTableColumn<T>[] | — | Columns with accessor, optional cell, and sorting. |
| getRowId | (row: T) => string | — | Stable unique row identity. |
| pageSize | number | 5 | Rows per page, normalized to a positive integer. |
| labels | object | English labels | Search, empty, pagination, and page labels. |
Accessibility
Rules that should remain intact when adapting the component to a product.
Provide a descriptive caption and stable row IDs. Sort headers expose aria-sort and pagination announces its position.
Retain keyboard focus styles and test the composition with keyboard navigation.
Use className for visual customization; preserve the primitive ARIA attributes.