Skip to Content

Data Table

A table with sorting, row selection, search, filters, column visibility and CSV export, built on TanStack Table.

10 rows
Invoice
Customer
Amount
Status
Due
INV-1042Northwind Traders$12,400paid2026-10-04
INV-1043Globex Corporation$8,250open2026-11-18
INV-1044Initech$3,120overdue2026-10-29
INV-1045Umbrella Health$21,900paid2026-10-12
INV-1046Hooli$5,600open2026-11-25
INV-1047Stark Logistics$18,750paid2026-10-20
INV-1048Wayne Freight$940draft2026-12-02
INV-1049Acme Supplies$7,300overdue2026-10-15
INV-1050Soylent Foods$15,200open2026-11-30
INV-1051Cyberdyne Systems$2,680paid2026-10-08
import { Badge } from "@dapplelight/signet-ui/components/badge"
import { DataTable, type DataTableProps } from "@dapplelight/signet-ui/components/data-table"

type Invoice = {
  id: string
  customer: string
  amount: number
  status: "paid" | "open" | "overdue" | "draft"
  due: string
}

const invoices: Invoice[] = [
  { id: "INV-1042", customer: "Northwind Traders", amount: 12400, status: "paid", due: "2026-10-04" },
  { id: "INV-1043", customer: "Globex Corporation", amount: 8250, status: "open", due: "2026-11-18" },
  { id: "INV-1044", customer: "Initech", amount: 3120, status: "overdue", due: "2026-10-29" },
  { id: "INV-1045", customer: "Umbrella Health", amount: 21900, status: "paid", due: "2026-10-12" },
  { id: "INV-1046", customer: "Hooli", amount: 5600, status: "open", due: "2026-11-25" },
  { id: "INV-1047", customer: "Stark Logistics", amount: 18750, status: "paid", due: "2026-10-20" },
  { id: "INV-1048", customer: "Wayne Freight", amount: 940, status: "draft", due: "2026-12-02" },
  { id: "INV-1049", customer: "Acme Supplies", amount: 7300, status: "overdue", due: "2026-10-15" },
  { id: "INV-1050", customer: "Soylent Foods", amount: 15200, status: "open", due: "2026-11-30" },
  { id: "INV-1051", customer: "Cyberdyne Systems", amount: 2680, status: "paid", due: "2026-10-08" },
]

const statusVariant = {
  paid: "default",
  open: "secondary",
  overdue: "destructive",
  draft: "outline",
} as const

const columns: DataTableProps<Invoice>["columns"] = [
  { accessorKey: "id", header: "Invoice" },
  { accessorKey: "customer", header: "Customer" },
  {
    accessorKey: "amount",
    header: "Amount",
    cell: ({ row }) => `$${row.original.amount.toLocaleString()}`,
  },
  {
    accessorKey: "status",
    header: "Status",
    meta: { filter: "facet" },
    cell: ({ row }) => (
      <Badge variant={statusVariant[row.original.status]}>{row.original.status}</Badge>
    ),
  },
  { accessorKey: "due", header: "Due" },
]

export function Demo() {
  return (
    <div className="w-full">
      <DataTable columns={columns} data={invoices} getRowId={(r) => r.id} />
    </div>
  )
}

Installation

npm i @dapplelight/signet-ui

Usage

import { DataTable } from "@dapplelight/signet-ui/components/data-table"
import { columns, invoices } from "./invoices"

<DataTable columns={columns} data={invoices} getRowId={(row) => row.id} sortable />

Examples

Sorting

10 rows
INV-1042Northwind Traders$12,400paid2026-10-04
INV-1043Globex Corporation$8,250open2026-11-18
INV-1044Initech$3,120overdue2026-10-29
INV-1045Umbrella Health$21,900paid2026-10-12
INV-1046Hooli$5,600open2026-11-25
INV-1047Stark Logistics$18,750paid2026-10-20
INV-1048Wayne Freight$940draft2026-12-02
INV-1049Acme Supplies$7,300overdue2026-10-15
INV-1050Soylent Foods$15,200open2026-11-30
INV-1051Cyberdyne Systems$2,680paid2026-10-08
import { DataTable } from "@dapplelight/signet-ui/components/data-table"
import { columns, invoices } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  return (
    <div className="w-full">
      <DataTable columns={columns} data={invoices} getRowId={(r) => r.id} sortable />
    </div>
  )
}

Row selection

10 rows
Invoice
Customer
Amount
Status
Due
INV-1042Northwind Traders$12,400paid2026-10-04
INV-1043Globex Corporation$8,250open2026-11-18
INV-1044Initech$3,120overdue2026-10-29
INV-1045Umbrella Health$21,900paid2026-10-12
INV-1046Hooli$5,600open2026-11-25
INV-1047Stark Logistics$18,750paid2026-10-20
INV-1048Wayne Freight$940draft2026-12-02
INV-1049Acme Supplies$7,300overdue2026-10-15
INV-1050Soylent Foods$15,200open2026-11-30
INV-1051Cyberdyne Systems$2,680paid2026-10-08
import { Button } from "@dapplelight/signet-ui/components/button"
import { DataTable } from "@dapplelight/signet-ui/components/data-table"
import { columns, invoices } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  return (
    <div className="w-full">
      <DataTable
        columns={columns}
        data={invoices}
        getRowId={(r) => r.id}
        selectable
        bulkActions={(selected) => (
          <Button size="sm" variant="outline">
            Send reminder to {selected.length}
          </Button>
        )}
      />
    </div>
  )
}

Search, columns and export

10 rows
INV-1042Northwind Traders$12,400paid2026-10-04
INV-1043Globex Corporation$8,250open2026-11-18
INV-1044Initech$3,120overdue2026-10-29
INV-1045Umbrella Health$21,900paid2026-10-12
INV-1046Hooli$5,600open2026-11-25
INV-1047Stark Logistics$18,750paid2026-10-20
INV-1048Wayne Freight$940draft2026-12-02
INV-1049Acme Supplies$7,300overdue2026-10-15
INV-1050Soylent Foods$15,200open2026-11-30
INV-1051Cyberdyne Systems$2,680paid2026-10-08
import { DataTable } from "@dapplelight/signet-ui/components/data-table"
import { columns, invoices } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  return (
    <div className="w-full">
      <DataTable
        columns={columns}
        data={invoices}
        getRowId={(r) => r.id}
        sortable
        searchable={{ placeholder: "Search invoices" }}
        columnsMenu
        exportFilename="invoices"
      />
    </div>
  )
}

Clickable rows

10 rows
Invoice
Customer
Amount
Status
Due
INV-1042Northwind Traders$12,400paid2026-10-04
INV-1043Globex Corporation$8,250open2026-11-18
INV-1044Initech$3,120overdue2026-10-29
INV-1045Umbrella Health$21,900paid2026-10-12
INV-1046Hooli$5,600open2026-11-25
INV-1047Stark Logistics$18,750paid2026-10-20
INV-1048Wayne Freight$940draft2026-12-02
INV-1049Acme Supplies$7,300overdue2026-10-15
INV-1050Soylent Foods$15,200open2026-11-30
INV-1051Cyberdyne Systems$2,680paid2026-10-08

Click a row

import { useState } from "react"
import { DataTable } from "@dapplelight/signet-ui/components/data-table"
import { columns, invoices, type Invoice } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  const [open, setOpen] = useState<Invoice | null>(null)
  return (
    <div className="w-full space-y-2">
      <DataTable
        columns={columns}
        data={invoices}
        getRowId={(r) => r.id}
        onRowClick={setOpen}
        getRowLabel={(r) => `Open ${r.id} for ${r.customer}`}
      />
      <p className="text-sm text-muted-foreground">
        {open ? `${open.id}: ${open.customer}` : "Click a row"}
      </p>
    </div>
  )
}

Empty

0 rows
Invoice
Customer
Amount
Status
Due
No invoices yet.
import { DataTable } from "@dapplelight/signet-ui/components/data-table"
import { columns } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  return (
    <div className="w-full">
      <DataTable columns={columns} data={[]} emptyMessage="No invoices yet." />
    </div>
  )
}

API Reference

DataTable

Every feature is off by default and opt-in by prop. There is no built-in pagination: scroll long lists with virtual.

PropTypeDefaultDescription
columnsColumnDef<DataTableFeatures, TData, unknown>[]requiredTanStack column definitions. Set meta.filter to "facet" or "text" for a toolbar filter, and meta.filterLabel to name it.
dataTData[]requiredThe rows.
getRowId(row: TData, index: number) => stringrow indexStable row ids, for selection and activeRowId.
sortablebooleanfalseClick a header to sort; shift-click adds a column.
selectablebooleanfalseCheckbox column, select-all header and a bulk-actions bar.
selectedRowIdsreadonly string[]noneControlled selection.
onSelectedRowIdsChange(ids: string[]) => voidnoneCalled when selection changes.
bulkActions(selected: TData[]) => ReactNodenoneRendered in the bulk bar while rows are selected.
searchableboolean | { placeholder?: string }falseA search box across every visible column.
columnsMenubooleanfalseA menu to show and hide columns.
exportFilenamestringnoneAdds an export button that downloads the current view as <name>.csv.
onRowClick(row: TData) => voidnoneMakes rows clickable and keyboard focusable.
getRowLabel(row: TData) => stringnoneAccessible name for a clickable row.
activeRowIdstringnoneRow marked data-active and scrolled into view.
emptyMessagestringnoneShown when there are no rows.
virtual{ rowHeight: number; height: number | string; overscan?: number }noneRender only visible rows, under a sticky header. Keep cells to one line.
viewDataTableViewnoneControlled filters, sorting and column visibility.
defaultViewDataTableViewemptyStarting view when uncontrolled.
onViewChange(view: DataTableView) => voidnoneCalled when the view changes.
savedViews{ views: SavedView[]; onSave: (name, view) => void; onDelete?: (id) => void }noneNamed views in the toolbar.
manualbooleanfalseThe server filters and sorts; data is shown as given.
facetCountsRecord<string, Record<string, number>>computedServer-side counts per facet value.
totalnumberdata.lengthUnfiltered row count, for "12 of 10,000".
tableRefMutableRefObject<Table | undefined>noneExposes the TanStack table instance.
classNamestringnoneClass for the root.

TruncatedCell

PropTypeDefaultDescription
childrenReactNoderequiredCell content; a tooltip shows when a string or number is cut off.
classNamestringnoneClass for the cell.