sabo/src/components/dashboard/data-table.tsx
The actual implementation uses
@tanstack/react-table + @dnd-kit for advanced features (sorting, filtering, drag-drop). See the file for full example.When to use
- Present datasets with sorting, filtering, pagination in the dashboard context.
Usage
Styling tip
- Keep columns minimal; move heavy controls to toolbar or row actions.
Key features
The actualdata-table.tsx implementation includes:
- @tanstack/react-table: Column sorting, filtering, pagination
- @dnd-kit: Drag-and-drop row reordering
- Toolbar: Search, filters, and column visibility toggles
- Responsive: Horizontal scroll on overflow
The component is a complex example. Review
sabo/src/components/dashboard/data-table.tsx for the full implementation with TanStack Table and DnD Kit.Steps
1
Define columns
Start with 2–4 key columns. Use
truncate for long text.2
Add sorting/filtering
For simple tables, implement client-side sorting with
Array.sort(). For large datasets, use TanStack Table with server-side pagination.3
Row actions
Add a compact actions column with a dropdown menu for edit/delete/view:
Troubleshooting
- Table overflowing viewport
- Wrap
<Table>in adivwithoverflow-x-auto
- Wrap
- Sorting not working
- Ensure
useStatefor sort state andArray.sort()callback are wired correctly
- Ensure
- DnD conflicts with click events
- Use event stopPropagation in row click handlers