Loading component…
Loading component…
Spreadsheet-style table: select cells and ranges, edit in place, copy and paste, undo and sort
To reuse this local React demo, copy all files from the Code tab into the same folder, then import DataTable from ./data-table.
import { DataTable, TextColumnIcon, TagColumnIcon } from "@/components/ui/data-table";
const columns = [
{ key: "tool", label: "Tool", icon: <TextColumnIcon />, type: "title" },
{ key: "category", label: "Category", icon: <TagColumnIcon />, type: "tag" },
{ key: "website", label: "Website", type: "link" },
{ key: "seats", label: "Seats", type: "number" },
];
export function Stack() {
return (
<DataTable
title="Design Stack"
columns={columns}
rows={rows}
tagTones={{ Design: "violet" }}
onRowsChange={save}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| title | string | Heading in the gray tray, also the grid's accessible name | |
| icon | ReactNode | Icon in front of the heading | |
| columns | DataColumn[] | key, label, icon, width, type (title, tag, link, number, text), editable, options for tags and format for numbers – numbers default to grouped digits with a real minus sign (12,345,679 · −4,200) | |
| rows | DataRow[] | Starting rows – an id, an optional logo and a value per column key | |
| tagTones | Record<string, TagTone> | Tag color per tag text: blue, violet, pink, green, amber or gray | |
| editable | boolean | true | false keeps selection and copy, but turns off editing, paste, delete and Add row |
| onRowsChange | (rows: DataRow[]) => void | Called with all rows after every edit, paste, clear, delete, undo or redo | |
| onSelectionChange | (ids: string[]) => void | Called with the ids of the checked rows | |
| className | string | Extra class on the tray |
The table scrolls sideways inside the card on narrow screens instead of squeezing the columns
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"