Examples
Toolbar controls
Every built-in control — quick filter, column chooser, pivot toggle, chart, refresh, expand — can be a button, a menu item, or gone, from one prop.
Live demo
Toolbar controls
Toggle controls on and off · Collapse everything into the settings menu
import { useState } from "react"
import { ProGrid, type ProColumnDef, type ToolbarConfig, type ToolbarControl } from "@/components/pro-grid"
import { formatCurrency, operationOrders, type OperationOrder } from "@/lib/operations-data"
function StatusCell({ value }: { value: unknown }) {
const status = String(value)
return <span className={`order-status order-status--${status.toLowerCase().replaceAll(" ", "-")}`}>{status}</span>
}
const baseColumns: ProColumnDef<OperationOrder>[] = [
{ accessorKey: "id", header: "Order", size: 118, meta: { label: "Order", type: "string" } },
{ accessorKey: "customer", header: "Customer", size: 190, meta: { label: "Customer", type: "string" } },
{
accessorKey: "region",
header: "Region",
size: 145,
meta: {
label: "Region",
type: "string", filterVariant: "set",
filterOptions: ["North America", "Europe", "Asia Pacific", "Latin America"],
groupable: true,
pivotable: true,
},
},
{
accessorKey: "status",
header: "Status",
size: 120,
cell: ({ getValue }) => <StatusCell value={getValue()} />,
meta: {
label: "Status",
type: "string", filterVariant: "set",
filterOptions: ["On track", "At risk", "Delayed", "Complete"],
groupable: true,
pivotable: true,
},
},
{
accessorKey: "units",
header: "Units",
size: 88,
meta: { label: "Units", type: "number", align: "right", aggregable: true, defaultAgg: "sum" },
},
{
accessorKey: "revenue",
header: "Revenue",
size: 128,
meta: {
label: "Revenue",
type: "number",
align: "right",
aggregable: true,
defaultAgg: "sum",
formatValue: (value) => formatCurrency(Number(value)),
},
},
]
const layoutDemoRows = operationOrders.slice(0, 40)
const TOOLBAR_DEMO_KEYS = [
"headerFilters",
"refresh",
"expand",
"groups",
"pivot",
"chart",
"columns",
] as const satisfies readonly (keyof ToolbarConfig)[]
type ToolbarDemoKey = (typeof TOOLBAR_DEMO_KEYS)[number]
const TOOLBAR_DEMO_LABELS: Record<ToolbarDemoKey, string> = {
headerFilters: "Header filters",
refresh: "Refresh",
expand: "Expand",
groups: "Groups",
pivot: "Pivot",
chart: "Chart",
columns: "Columns",
}
const TOOLBAR_PLACEMENTS: { value: ToolbarControl; label: string }[] = [
{ value: true, label: "Button" },
{ value: "menu", label: "Menu" },
{ value: false, label: "Off" },
]
const DEFAULT_TOOLBAR_DEMO_CONFIG: Record<ToolbarDemoKey, ToolbarControl> = {
headerFilters: "menu",
refresh: true,
expand: true,
groups: true,
pivot: true,
chart: true,
columns: true,
}
export function ToolbarControlsDocsDemo() {
const [config, setConfig] = useState(DEFAULT_TOOLBAR_DEMO_CONFIG)
const [settings, setSettings] = useState(true)
return (
<div className="space-y-3">
<div className="flex flex-wrap items-center gap-3 border-b border-border pb-3 text-sm">
<label className="flex cursor-pointer items-center gap-1.5 font-medium">
<input
type="checkbox"
checked={settings}
onChange={(e) => setSettings(e.target.checked)}
/>
Settings dropdown
</label>
{!settings && (
<span className="text-xs text-muted-foreground">
Off — every control below set to "Menu" falls back to its own button instead
of disappearing.
</span>
)}
</div>
<div className="grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2 lg:grid-cols-3">
{TOOLBAR_DEMO_KEYS.map((key) => (
<div key={key} className="flex items-center gap-2 text-sm">
<span className="w-28 shrink-0 text-muted-foreground">{TOOLBAR_DEMO_LABELS[key]}</span>
<div className="flex overflow-hidden rounded-md border border-border">
{TOOLBAR_PLACEMENTS.map((p) => (
<button
key={String(p.value)}
onClick={() => setConfig((c) => ({ ...c, [key]: p.value }))}
aria-pressed={config[key] === p.value}
className={`px-2 py-1 text-xs ${
config[key] === p.value ? "bg-primary text-primary-foreground" : "hover:bg-muted"
}`}
>
{p.label}
</button>
))}
</div>
</div>
))}
</div>
<ProGrid<OperationOrder>
columns={baseColumns}
data={layoutDemoRows}
getRowId={(row) => row.id}
height={340}
initialGrouping={["region"]}
title="Orders"
toolbar={{ ...config, settings }}
/>
</div>
)
}// 40 flat orders, grouped by region so `expand` and `groups`
// both have something to act on. Every toggle below writes straight into
// the `toolbar` prop — nothing else about the grid changes. Turning the
// settings dropdown off falls any control still set to "menu" back to a
// button rather than dropping it.
/** `Cancelled` is never generated below; the billing demo marks its own. */
type OrderStatus = "On track" | "At risk" | "Delayed" | "Complete" | "Cancelled"
interface OperationOrder extends Record<string, unknown> {
id: string
customer: string
channel: "Direct" | "Marketplace" | "Partner"
region: "North America" | "Europe" | "Asia Pacific" | "Latin America"
owner: string
status: OrderStatus
priority: "Critical" | "High" | "Normal"
units: number
revenue: number
margin: number
slaHours: number
updatedAt: string
}
const rows: OperationOrder[] = [
{
"id": "ORD-10482",
"customer": "Keystone Foods",
"channel": "Direct",
"region": "North America",
"owner": "Theo Martins",
"status": "Complete",
"priority": "Normal",
"units": 18,
"revenue": 1850,
"margin": 12,
"slaHours": 2,
"updatedAt": "2026-08-01T08:00:00.000Z"
},
{
"id": "ORD-10483",
"customer": "Atlas Manufacturing",
"channel": "Partner",
"region": "North America",
"owner": "Jon Bell",
"status": "Delayed",
"priority": "Critical",
"units": 55,
"revenue": 9769,
"margin": 25,
"slaHours": 7,
"updatedAt": "2026-08-02T09:00:00.000Z"
},
// …38 more rows
]Header filters
Refresh
Expand
Groups
Pivot
Chart
Columns
Orders
Row GroupsRegion
Region
Order
Customer
Status
Units
Revenue
Total
Sum8580
Sum$1,742,820
40 rows
Things to try
- Toggle controls on and off
- Collapse everything into the settings menu
The Code tab above is the component rendering this page; the Data tab is what reaches the grid. The props behind it are explained in Layout.