Tablealternative
Use Table for simple semantic HTML tablesDataTable
Data table with sorting, selection, and column management. Powered by TanStack Table.
Setup
import { DataTable } from '@fragments-sdk/ui';Examples
Default
Basic data table with status badges and role columns
Loading preview...
Rich Cells
Custom cells with avatars, stacked text, and column sizing
Loading preview...
Sortable
Click column headers to sort ascending or descending
Loading preview...
Checkbox Selection
Select rows with header checkbox for select-all and individual row checkboxes
Loading preview...
Expandable Rows
Hierarchical data with collapsible sub-rows, like a file tree
Loading preview...
With Filters
Combine with search input and menu dropdowns for filtered views
Loading preview...
Clickable Rows
Rows respond to click and keyboard activation
Loading preview...
Striped
Alternating row backgrounds for dense data
Loading preview...
Empty State
Display when no data matches the current filters
Loading preview...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
columnsRequired | array | Not set | Column definitions |
dataRequired | array | Not set | Data rows to display |
getRowId | function | Not set | Unique key extractor for each row |
sortable | boolean | false | Enable column sorting |
sorting | array | Not set | Controlled sorting state |
onSortingChange | function | Not set | Sorting change handler |
selectable | boolean | false | Enable row selection |
showCheckbox | boolean | false | Show checkbox column for row selection (requires selectable) |
rowSelection | object | Not set | Controlled row selection state |
onRowSelectionChange | function | Not set | Row selection change handler |
onRowClick | function | Not set | Handler for row clicks/keyboard activation. Called as (row, event) |
getSubRows | function | Not set | Extract sub-rows for expandable tree tables |
expanded | union | Not set | Controlled expanded state |
onExpandedChange | function | Not set | Expanded state change handler |
emptyMessage | string | No data available | Message when no data |
size | enumsmmd | md | Table density |
caption | string | Not set | Visible caption for the table |
captionHidden | boolean | false | Hide caption visually but keep it for screen readers |
striped | boolean | false | Show alternating row backgrounds |
bordered | boolean | false | Wrap table in a bordered container |
wrapperClassName | string | Not set | Additional class name for the outer wrapper div |
wrapperProps | object | Not set | Props forwarded to the outer wrapper div (id, aria-*, data-*, handlers) |
Usage Guidelines
When to use
- Displaying structured, tabular data with sorting
- Data that users need to scan, compare, and act upon
- Lists with multiple attributes per item that need sorting or selection
- Data-rich tables requiring column sizing and row clicks
- Hierarchical data with expandable sub-rows
When not to use
- Simple static tables (use Table component)
- Simple lists (use List component)
- Card-based layouts (use Grid with Cards)
- Small screens (consider card or list view)
Best practices
- Keep columns to a reasonable number (5-7 max)
- Use consistent alignment (numbers right, text left)
- Provide meaningful empty states
- Consider mobile responsiveness
- Use showCheckbox for bulk selection workflows
Accessibility
- Proper table semantics with headers
- Sortable columns are keyboard accessible
- Row selection checkboxes include aria-labels
- Expand/collapse buttons have aria-expanded state