Skip to Content

Data Grid

A spreadsheet-like grid with inline editing, keyboard navigation, copy and paste, selection and sorting.

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 { useState } from "react"
import { DataGrid, type DataGridColumn } from "@dapplelight/signet-ui/components/data-grid"

type Invoice = {
  id: string
  customer: string
  amount: number
  status: string
  due: string
  paid: boolean
}

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

const columns: DataGridColumn<Invoice>[] = [
  { id: "id", header: "Invoice", editable: false, width: 110 },
  { id: "customer", header: "Customer", width: 200 },
  {
    id: "amount",
    header: "Amount",
    type: "number",
    width: 120,
    format: (v) => `$${Number(v).toLocaleString()}`,
  },
  {
    id: "status",
    header: "Status",
    type: "select",
    width: 120,
    options: [
      { value: "draft", label: "Draft" },
      { value: "open", label: "Open" },
      { value: "paid", label: "Paid" },
      { value: "overdue", label: "Overdue" },
    ],
  },
  { id: "due", header: "Due", type: "date", width: 130 },
  { id: "paid", header: "Paid", type: "checkbox", width: 80 },
]

export function Demo() {
  const [rows, setRows] = useState(invoices)
  return (
    <div className="w-full">
      <DataGrid
        aria-label="Invoices"
        columns={columns}
        rows={rows}
        height={340}
        getRowId={(r) => r.id}
        onChange={(changes) => {
          setRows((prev) =>
            prev.map((r) => {
              const mine = changes.filter((c) => c.rowId === r.id)
              return mine.length ? { ...r, ...Object.fromEntries(mine.map((c) => [c.columnId, c.value])) } : r
            }),
          )
        }}
      />
    </div>
  )
}

Installation

npm i @dapplelight/signet-ui

Usage

import { DataGrid } from "@dapplelight/signet-ui/components/data-grid"
import { invoices } from "./invoices"
import { save } from "./actions"

<DataGrid
  aria-label="Invoices"
  columns={[{ id: "customer", header: "Customer" }]}
  rows={invoices}
  getRowId={(row) => row.id}
  onChange={save}
/>

Examples

Row selection

INV-1042Northwind Traders$12,400Paid
INV-1043Globex Corporation$8,250Open
INV-1044Initech$3,120Overdue
INV-1045Umbrella Health$21,900Paid
INV-1046Hooli$5,600Open
INV-1047Stark Logistics$18,750Paid
INV-1048Wayne Freight$940Draft
INV-1049Acme Supplies$7,300Overdue
INV-1050Soylent Foods$15,200Open
INV-1051Cyberdyne Systems$2,680Paid
1 selected

1 selected

import { useState } from "react"
import { DataGrid } from "@dapplelight/signet-ui/components/data-grid"
import { invoices, columns } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  const [selected, setSelected] = useState<string[]>(["INV-1043"])
  return (
    <div className="w-full space-y-2">
      <DataGrid
        aria-label="Invoices"
        columns={columns.slice(0, 4)}
        rows={invoices}
        height={300}
        selectable
        selectedRowIds={selected}
        onSelectedRowIdsChange={setSelected}
        getRowId={(r) => r.id}
      />
      <p className="text-sm text-muted-foreground">{selected.length} selected</p>
    </div>
  )
}

Validation

INV-1042Northwind Traders12,400
INV-1043Globex Corporation8,250
INV-1044Initech3,120
INV-1045Umbrella Health21,900
INV-1046Hooli5,600
INV-1047Stark Logistics18,750
INV-1048Wayne Freight940
INV-1049Acme Supplies7,300
INV-1050Soylent Foods15,200
INV-1051Cyberdyne Systems2,680
import { useState } from "react"
import { DataGrid, type DataGridColumn } from "@dapplelight/signet-ui/components/data-grid"
import { invoices, type Invoice } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  const [rows, setRows] = useState(invoices)
  const cols: DataGridColumn<Invoice>[] = [
    { id: "id", header: "Invoice", editable: false, width: 110 },
    { id: "customer", header: "Customer", width: 200 },
    {
      id: "amount",
      header: "Amount",
      type: "number",
      width: 140,
      validate: (v) => (typeof v === "number" && v < 0 ? "Amount can't be negative." : undefined),
    },
  ]
  return (
    <div className="w-full">
      <DataGrid
        aria-label="Invoice amounts"
        columns={cols}
        rows={rows}
        height={260}
        getRowId={(r) => r.id}
        onChange={(changes) => {
          setRows((prev) =>
            prev.map((r) => {
              const mine = changes.filter((c) => c.rowId === r.id)
              return mine.length ? { ...r, ...Object.fromEntries(mine.map((c) => [c.columnId, c.value])) } : r
            }),
          )
        }}
      />
    </div>
  )
}

Read only

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 { DataGrid } from "@dapplelight/signet-ui/components/data-grid"
import { invoices, columns } from "./invoices"

// uses the invoices and columns from the first example
export function Demo() {
  return (
    <div className="w-full">
      <DataGrid
        aria-label="Invoices"
        columns={columns.map((c) => ({ ...c, editable: false }))}
        rows={invoices}
        height={300}
        getRowId={(r) => r.id}
      />
    </div>
  )
}

API Reference

DataGrid

Click a header to sort, drag its edge to resize. Rows are virtualised and one line tall, and the grid has no pagination. Arrow keys move, Enter edits, and ranges copy and paste as TSV.

PropTypeDefaultDescription
columnsDataGridColumn<T>[]requiredColumn definitions, see below.
rowsT[]requiredThe data. Apply saved changes back to it.
getRowId(row: T, index: number) => stringrequiredStable id for each row.
onChange(changes: DataGridChange<T>[]) => Promise<DataGridFailure[] | undefined> | DataGridFailure[] | undefinednoneEdits, pastes and clears, as a batch. The grid shows new values at once; a throw reverts them with an error on each cell, and returned failures do so for just those cells.
selectablebooleanfalseAdds a checkbox column and Shift+Space row selection.
selectedRowIdsreadonly string[]noneControlled selection.
onSelectedRowIdsChange(ids: string[]) => voidnoneCalled when selection changes.
rowHeightnumber36Row height in px.
heightnumber | string480Height of the scrolling body.
overscannumber8Extra rows rendered outside the viewport.
aria-labelstringnoneAccessible name.
aria-labelledbystringnoneId of the element that names the grid.
labelsPartial<DataGridLabels>DEFAULT_DATA_GRID_LABELSOverride the grid's strings.
classNamestringnoneClass for the root.
classNamesPartial<Record<"root" | "table" | "header" | "headerCell" | "row" | "cell" | "editor" | "error", string>>{}Class per part.

DataGridColumn

PropTypeDefaultDescription
idkeyof TrequiredThe row key this column reads and writes.
headerstringrequiredHeader text.
type"text" | "number" | "select" | "date" | "checkbox""text"Editor and paste parsing. Dates are YYYY-MM-DD strings.
options{ value: string; label: string }[]noneChoices for type: "select".
editablebooleantrueAllow editing.
sortablebooleantrueAllow sorting.
widthnumber160Starting width in px.
minWidthnumber40Smallest width when resizing.
format(value: unknown, row: T) => ReactNodenoneHow the value shows when not editing.
parse(text: string, row: T) => { value: unknown } | { error: string }by typeText (typed or pasted) to a value.
validate(value: unknown, row: T) => string | undefinednoneReturn a message to refuse a value before it is saved.