Patterns

Data table — editable (bordered)

Click a cell: Enter or leaving saves, Esc cancels. Tick rows for bulk Edit or Delete. Hours must be 1–24; saves take 400 ms like a real API.

1–8 of 8
1 / 1

Import#

Everything comes from the package root. The example above uses:

your-component.tsx
import { type ColumnDef, DataTable, StatusBadge } from "@waveinno/ui";

Props#

Read from the source of this version, so they match the code exactly.

<DataTable>

src/components/patterns/data-table.tsx
PropTypeDefaultDescription
columnsrequiredColumnDef<T, unknown>[]—
datarequiredT[]—
getRowIdrequired(row: T) => string—
onRowClick(row: T) => void—
activeIdstring | null—Row currently shown in the drawer — highlighted, not navigated to.
searchPlaceholderstring"Search…"
pageSizenumber12
footerReact.ReactNode—Rendered in <tfoot>: totals turn a table into a report (§8).
emptyStateReact.ReactNode—
savedViewsSavedView[][]
toolbarExtraReact.ReactNode—
exportNamestring"waveinno-export"
defaultFiltersFilterStateEMPTY_FILTERSFilters to start with (e.g. from the URL).
onFiltersChange(filters: FilterState) => void—Told every time the filters change — save them, or send them to the API.
manualFilteringbooleanfalseThe server filters: rules are shown and reported but rows are not filtered here.
filterLabelsPartial<FilterLabels>—
variant"default" | "striped" | "bordered" | "cards" | "minimal""default"The look: `default` (hairline rows), `striped` (zebra, for long scans), `bordered` (a spreadsheet grid — the one for editing), `cards` (every row a floating card, for few, rich rows), `minimal` (no frame, inside cards and drawers).
onCellEdit(row: T, columnId: string, value: string) => void | Promise<void>—Save an edited cell. Return a promise to show a spinner; reject to keep the editor open.
onBulkEdit(rows: T[], columnId: string, value: string) => void | Promise<void>—Save one value into many rows (the bulk bar's Edit). Without it, the table calls `onCellEdit` once per selected row.
getRowLabel(row: T) => string—Name of a row in confirmations ("Delete these 3: …"). Defaults to the row id.
onBulkDelete(rows: T[]) => void | Promise<void>—Delete the selected rows (the bulk bar's Delete, after a confirmation).
bulkActions(rows: T[], clear: () => void) => React.ReactNode—Extra buttons in the bulk bar, e.g. Assign or Archive. `clear` empties the selection.
classNamestring—

<StatusBadge>

src/components/ui/badge.tsx
PropTypeDefaultDescription
labelrequiredstring—
toneTone"neutral"
variant"soft" | "solid" | "outline" | "dot" | "gradient" | "live"—
classNamestring—

Install#

If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.

$ npm install @waveinno/ui