Skip to main content
Location: 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 actual data-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.
Place filters in a toolbar above the table. Avoid cramming controls into header cells.
3

Row actions

Add a compact actions column with a dropdown menu for edit/delete/view:

Troubleshooting

  • Table overflowing viewport
    • Wrap <Table> in a div with overflow-x-auto
  • Sorting not working
    • Ensure useState for sort state and Array.sort() callback are wired correctly
  • DnD conflicts with click events
    • Use event stopPropagation in row click handlers