Skip to main content

Example: Static lookup table

Ideal for feature flags, permission catalogs, or status dictionaries that never hit a list endpoint.

"use client";

import type { ColumnDef } from "@tanstack/react-table";
import { DataTable, DataTableColumnHeader } from "@/components/datatable";
import { Badge } from "@/components/ui/badge";

type Flag = {
id: string;
name: string;
stage: "dev" | "beta" | "ga";
description: string;
};

const FLAGS: Flag[] = [
{
id: "billing.v2",
name: "Billing v2",
stage: "beta",
description: "New invoice pipeline",
},
{
id: "auth.passkeys",
name: "Passkeys",
stage: "ga",
description: "WebAuthn sign-in",
},
{
id: "ui.density",
name: "Compact density",
stage: "dev",
description: "Tighter table spacing",
},
];

const columns: ColumnDef<Flag>[] = [
{
id: "name",
accessorKey: "name",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Flag" />
),
enableSorting: true,
enableColumnFilter: true,
meta: { variant: "text", label: "Flag", placeholder: "Search flags..." },
},
{
id: "stage",
accessorKey: "stage",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Stage" />
),
enableColumnFilter: true,
meta: {
variant: "multiSelect",
label: "Stage",
options: [
{ label: "Dev", value: "dev" },
{ label: "Beta", value: "beta" },
{ label: "GA", value: "ga" },
],
},
cell: ({ row }) => <Badge variant="secondary">{row.original.stage}</Badge>,
},
{
id: "description",
accessorKey: "description",
header: "Description",
enableColumnFilter: true,
meta: { variant: "text", label: "Description" },
},
];

export function FeatureFlagsTable() {
return (
<DataTable<Flag>
columns={columns}
source={{ type: "client", data: FLAGS }}
enableToolbar
enablePagination
showTotalRows
getRowId={(r) => r.id}
initialState={{
sorting: [{ id: "name", desc: false }],
pagination: { pageIndex: 0, pageSize: 20 },
}}
/>
);
}

Ship the array in the bundle or inject it from config — the DataTable only needs data.