Data Grid
@allem-ui/data-grid
Advanced data table with sorting, filtering, row selection, and pagination. Built on TanStack Table.
Installation
npm install @allem-ui/data-grid
Basic Usage
| | |
|---|
| Alice Johnson | alice@example.com | Admin |
| Bob Smith | bob@example.com | Editor |
| Carol Davis | carol@example.com | Viewer |
| Dan Wilson | dan@example.com | Editor |
With Sorting & Filtering
| | |
|---|
| Alice Johnson | alice@example.com | Admin |
| Bob Smith | bob@example.com | Editor |
| Carol Davis | carol@example.com | Viewer |
| Dan Wilson | dan@example.com | Editor |
Features
- ✓ Column sorting (click headers)
- ✓ Global search filtering
- ✓ Row selection with checkboxes
- ✓ Pagination with page size control
- ✓ Loading and empty states
- ✓ Custom cell renderers
Props
| Prop | Type | Default | Description |
|---|
| data* | T[] | — | Array of data to display |
| columns* | ColumnDef<T>[] | — | Column definitions (from TanStack Table) |
| enableSorting | boolean | false | Enable column sorting |
| enableFiltering | boolean | false | Enable global search filter |
| enableRowSelection | boolean | false | Enable row selection checkboxes |
| enablePagination | boolean | false | Enable pagination |
| pageSize | number | 10 | Rows per page |
| loading | boolean | false | Show loading overlay |
| emptyMessage | string | — | Message when no data |
| onRowClick | (row: T) => void | — | Row click handler |
DataGridToolbar Props
| Prop | Type | Default | Description |
|---|
| globalFilter* | string | — | Current search value |
| onGlobalFilterChange* | (value: string) => void | — | Search change handler |
| selectedCount | number | — | Number of selected rows |
| totalCount | number | — | Total rows |
| className | string | — | Additional CSS classes |
| children | ReactNode | — | Extra toolbar content |
DataGridPagination Props
| Prop | Type | Default | Description |
|---|
| pageIndex* | number | — | Current page index |
| pageCount* | number | — | Total pages |
| pageSize* | number | — | Rows per page |
| onPageChange* | (page: number) => void | — | Page change handler |
| onPageSizeChange | (size: number) => void | — | Page size change handler |
| totalRows* | number | — | Total row count |
| className | string | — | Additional CSS classes |
DataGridColumnHeader Props
| Prop | Type | Default | Description |
|---|
| sorted* | false | "asc" | "desc" | — | Current sort state |
| onSort* | () => void | — | Sort toggle handler |
| children* | ReactNode | — | Header label |
| className | string | — | Additional CSS classes |