Examples
Filtering
Text, number, date, set and boolean filters driven by column type. Every surface — header funnel, filter bar, side rail, dialog — edits one filter model.
Live demo
Filtering
Open a header filter · Combine two conditions · Move the filters to the rail · Clear everything from the toolbar
import { useState } from "react"
import { ProGrid, type FilterConfig, type ProColumnDef } 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 filterDemoRows = operationOrders.slice(0, 40)
const FILTER_PLACEMENTS = ["top", "left", "dialog", "none"] as const
export function FilteringDocsDemo() {
const [placement, setPlacement] =
useState<NonNullable<FilterConfig["placement"]>>("top")
const [headerFilters, setHeaderFilters] = useState(true)
return (
<div className="space-y-3">
<div className="flex flex-wrap items-center gap-3 text-sm">
<span className="text-muted-foreground">Placement</span>
<div className="flex overflow-hidden rounded-md border border-border">
{FILTER_PLACEMENTS.map((p) => (
<button
key={p}
onClick={() => setPlacement(p)}
aria-pressed={placement === p}
className={`px-3 py-1 text-xs capitalize ${
placement === p ? "bg-primary text-primary-foreground" : "hover:bg-muted"
}`}
>
{p}
</button>
))}
</div>
<label className="flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground">
<input
type="checkbox"
checked={headerFilters}
onChange={(e) => setHeaderFilters(e.target.checked)}
/>
Header funnels
</label>
</div>
<ProGrid<OperationOrder>
columns={baseColumns}
data={filterDemoRows}
getRowId={(row) => row.id}
height={340}
title="Orders"
filters={{ placement, headerFilters }}
/>
</div>
)
}// 40 flat orders. Filtering is entirely a function of the column
// metadata: a column gets a filter by declaring `type`, and `filterOptions`
// is what turns a string column into a checkbox list.
/** `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
]
// Whatever surface edits it, a column filter is this one shape — the same
// object client mode evaluates and server mode sends.
import type { ColumnType } from "@/components/pro-grid"
type FilterOperator =
// string
| "contains"
| "notContains"
| "startsWith"
| "endsWith"
// string + number + date + boolean
| "equals"
| "notEquals"
// number + date
| "gt"
| "gte"
| "lt"
| "lte"
| "inRange"
// membership — "is any of" for a scalar, "has any of" for an array cell
| "in"
| "notIn"
// array only
| "hasAll"
// date only — `value` is a day count relative to when the filter runs
| "inLast"
| "inNext"
// any type
| "blank"
| "notBlank"
type ConditionJoin = "AND" | "OR"
type FilterCondition = {
operator: FilterOperator
value: unknown
/** Upper bound — `inRange` only. */
valueTo?: unknown
}
/** One column's filter: up to two conditions combined with AND/OR. */
type ColumnFilter = {
id: string
/**
* The column's primitive. Carried on the filter rather than looked up, so a
* filter stays self-describing once it has left the grid — the serialized
* `?filters=` blob and a server-side evaluator both need to know how to
* compare the values, and neither can see the column definitions.
*/
type: ColumnType
conditions: FilterCondition[]
join: ConditionJoin
}
const columnFilters: ColumnFilter[] = [
{
id: "region",
type: "string",
conditions: [{ operator: "in", value: ["Europe", "Asia Pacific"] }],
join: "AND",
},
{
id: "units",
type: "number",
conditions: [{ operator: "gt", value: "120" }],
join: "AND",
},
]Placement
Orders
FiltersNo filters yet — add one →
Order
Customer
Region
Status
Units
Revenue
Total
Sum8580
Sum$1,742,820
40 rows
Things to try
- Open a header filter
- Combine two conditions
- Move the filters to the rail
- Clear everything from the toolbar
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 Filtering.