CLI previewInstall commands shown on this site are not released yet.

DocsComponentsData Display

DataTable

React example follows below.
ts
import { DataTable, Badge } from "@grassroot/ui-react";
const statusVariant = { healthy: "success", degraded: "warning", down: "error" };
const serviceData = [
{ service: "ledger-api", p95: 142, status: "healthy" },
{ service: "billing-worker", p95: 88, status: "healthy" },
{ service: "analytics-ingest", p95: 310, status: "degraded" },
];
const serviceColumns = [
{ key: "service", header: "Service", head: true },
{ key: "p95", header: "p95", num: true, render: (r) => `${r.p95}ms` },
{ key: "status", header: "Status", sortable: false, render: (r) => <Badge variant={statusVariant[r.status]}>{r.status}</Badge> },
];
<DataTable columns={serviceColumns} data={serviceData} defaultSort="p95" zebra />

No translated snippet for this adapter yet.

No translated snippet for this adapter yet.

No translated snippet for this adapter yet.

ts
import { Badge, DataTable } from "@grassroot/ui-solid";
const statusVariant = { healthy: "success", degraded: "warning", down: "error" };
const serviceData = [
{ service: "ledger-api", p95: 142, status: "healthy" },
{ service: "billing-worker", p95: 88, status: "healthy" },
{ service: "analytics-ingest", p95: 310, status: "degraded" },
];
const serviceColumns = [
{ key: "service", header: "Service", head: true },
{ key: "p95", header: "p95", num: true, render: (r) => `${r.p95}ms` },
{ key: "status", header: "Status", sortable: false, render: (r) => <Badge variant={statusVariant[r.status]}>{r.status}</Badge> },
];
export function Example() {
return (
<>
<Badge variant={statusVariant[r.status]}>{r.status}</Badge>
<DataTable columns={serviceColumns} data={serviceData} defaultSort="p95" zebra />
</>
);
}

Installation

bash
pnpm dlx grassroot add ui/data-table
bash
npx grassroot@latest add ui/data-table
bash
yarn dlx grassroot add ui/data-table
bash
bunx grassroot add ui/data-table

API Reference

DataTableProps
PropTypeDefault
columnsrequiredDataColumn<T>[]
datarequiredT[]
defaultSortInitial sort column key.(keyof T & string) | undefined
zebraAlternate row tint.boolean | undefinedfalse
classNamestring | undefined