Skip to content
Display

DataTable

Records with search, sorting across pages, columns, pagination and bulk actions.

import { DataTable } from "@flinbu/seed";

Components

Updated
dialogPublishedMei Chen237Aug 10
tabsPublishedTomás Gil234Aug 19
bannerPublishedAna Ruiz212Aug 5
popoverPublishedMei Chen209Aug 14
comboboxPublishedAna Ruiz184Aug 9
switchPublishedMei Chen181Aug 18
import { Button, DataTable } from "@flinbu/seed";
import { Archive, Plus } from "lucide-react";

<DataTable<Row> className="w-full" aria-label="Components" columns={COLUMNS} rows={ROWS} pageSize={6} noun={["component", "components"]} selectable
  defaultSort={{ key: "uses", dir: "desc" }}
  toolbar={<Button size="sm" leftIcon={<Plus />}>New component</Button>}
  bulkActions={(rows, clear) => <Button size="sm" variant="secondary" leftIcon={<Archive />} onClick={clear}>Archive {rows.length}</Button>} />

Use it for

  • Lists of components, tokens, people, versions.

Use something else for

  • A few rows with no actions: use Table.

Props

PropTypeDefaultDescription
columns{ key, header, render?, align?, sortable?, sortValue?, hideable? }[]–Columns.
rowsobject[]–Records.
rowKeystring(row, i) => key'id'Identity.
pageSizenumber10Rows per page.
noun[string, string]['row', 'rows']Summary words.
selectable / bulkActionsboolean / (rows, clear) => ReactNode–Selection.
sort / onSortChange{ key, dir }null–Sorting.
toolbarReactNode–Buttons on the right.
stackOnMobilebooleantrueBelow 768px each row is a card under a bar of sort buttons.
loading / empty / density / onRowClick…–More.

Accessibility

  • Sort headers are buttons with aria-sort.
  • Select all covers the current page.
  • A search with no results says so and offers to clear it.
  • On phones rows are cards; the sort buttons and select all stay above them, and every value keeps its header.