Features
Selection and clipboard
Select rows for actions or build spreadsheet-like cell ranges with pointer and keyboard input. Both modes are enabled by default and can be controlled independently.
Interaction model
- Click or drag to replace the active cell range. The cell you clicked is the anchor, drawn with a ring.
- Hold Shift while clicking or pressing an arrow key to extend from the anchor.
- Click a column header to select the whole column; Shift-click a second header to select the span.
- Use row checkboxes for record-level actions that should survive sorting. Starting a cell range clears them, and vice versa.
<ProGrid
columns={columns}
data={orders}
rowSelection
cellSelection
getRowId={(order) => order.id}
/>Keyboard
Once a cell has been clicked, the body has keyboard focus and these keys act on the range. Group summary rows are stepped over.
| Keys | Action |
|---|---|
| ↑ ↓ ← → | Move the active cell; the range collapses to it. |
| Shift + arrows | Extend the range from the anchor. |
| Home / End | First / last column of the row. With Ctrl, the first / last cell of the grid. |
| Page Up / Page Down | Move by a viewport of rows. |
| Ctrl + A | Select every cell. |
| Ctrl + C | Copy the range (or the checked rows). Ctrl + Shift + C includes the header row. |
| Esc | Clear the range. |
Cmd stands in for Ctrl on macOS.
Row and cell selection
Use the checkboxes for rows, or click and drag through cells to create a range.
import { useState } from "react"
import { ProGrid, 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 selectionDemoRows = operationOrders.slice(0, 24)
export function SelectionDocsDemo() {
const [selectionCount, setSelectionCount] = useState(0)
return (
<>
<div className="docs-demo__status" aria-live="polite">
<span>{selectionCount ? `${selectionCount} row${selectionCount === 1 ? "" : "s"} selected` : "Select rows or drag across cells"}</span>
<span>Arrows move · Shift extends · Ctrl/⌘+C copies</span>
</div>
<ProGrid<OperationOrder>
columns={baseColumns.slice(0, 5)}
data={selectionDemoRows}
getRowId={(row) => row.id}
height={360}
onStateChange={(state) => setSelectionCount(Object.keys(state.rowSelection).length)}
title="Pick fulfillment orders"
/>
</>
)
}// 24 orders. `getRowId` returns `order.id`, so a selection survives
// sorting, filtering, and paging.
/** `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"
},
// …22 more rows
]
// `onStateChange` reports the selection as an id-keyed map:
const rowSelection = { "ORD-10482": true, "ORD-10484": true }Pick fulfillment orders
Row actions
rowActions puts a ⋮ menu of record-level actions in the utility column, and the same affordance in its header for whatever is currently selected. The actions are yours: the grid renders the trigger and the menu and calls back.
itemstakes an array, or a function of the row when the menu has to vary — the usual reason being an action that does not apply to every record.hiddendrops an item;disabledgreys it but leaves it visible, which is the better choice when its absence would be puzzling.variantcolours an itemprimary,warningordestructive. It is styling only — a destructive action that needs confirming should ask in its ownonSelect, using whatever your application already uses for that.position: "trailing"moves the actions into their own column pinned to the right edge, instead of sharing the checkbox column.
<ProGrid
columns={columns}
data={orders}
getRowId={(order) => order.id}
rowActions={{
// "leading" (default) shares the checkbox column; "trailing" gets its own,
// pinned to the right edge.
position: "leading",
items: (row) => [
{ id: "edit", label: "Edit", icon: <Pencil />, onSelect: ({ row }) => edit(row.original) },
{
id: "delete",
label: "Delete",
icon: <Trash2 />,
variant: "destructive",
hidden: row.original.status === "Complete",
onSelect: ({ row }) => remove(row.original),
},
],
// The header menu, over the current selection.
bulkItems: [
{ id: "export", label: "Export selected", onSelect: ({ rows }) => exportRows(rows) },
],
}}
/>Group and aggregate rows never get a trigger: they stand for a bucket rather than a record, so a verb like Delete has nothing to act on. Narrow it further with isRowActionable.
Row actions
Open the ⋮ menu on any row, or select rows and use the menu in the header. Delete is hidden on completed orders.
import { useState } from "react"
import { Ban, Copy, Download, Pencil, Trash2 } from "lucide-react"
import type { Row } from "@tanstack/react-table"
import { ProGrid, type ProColumnDef, type RowAction } 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)),
},
},
]
/**
* Record-level actions in the utility column, beside the checkbox.
*
* `items` is a function here so Delete can withhold itself from an order that
* has already shipped — the common reason a menu varies per row. The header's
* `⋮` runs the same verbs over everything currently selected.
*/
export function RowActionsDocsDemo() {
const [log, setLog] = useState<string | null>(null)
const [rows, setRows] = useState(() => operationOrders.slice(0, 18))
const say = (message: string) => setLog(message)
// `items` is handed the TanStack row, as `onRowClick` and `rowClassName` are;
// the record itself is `row.original`.
const items = (row: Row<OperationOrder>): RowAction<OperationOrder>[] => {
const order = row.original
return [
{ id: "edit", label: "Edit order", icon: <Pencil />, onSelect: () => say(`Edit ${order.id}`) },
{ id: "duplicate", label: "Duplicate", icon: <Copy />, onSelect: () => say(`Duplicated ${order.id}`) },
{
id: "hold",
label: "Put on hold",
icon: <Ban />,
variant: "warning",
onSelect: () => say(`${order.id} put on hold`),
},
{
id: "delete",
label: "Delete order",
icon: <Trash2 />,
variant: "destructive",
// A shipped order is a record of something that happened; it is amended,
// not deleted. `hidden` drops the item rather than greying it out.
hidden: order.status === "Complete",
onSelect: () => {
setRows((prev) => prev.filter((r) => r.id !== order.id))
say(`Deleted ${order.id}`)
},
},
]
}
const bulkItems: RowAction<OperationOrder>[] = [
{
id: "export",
label: "Export selected",
icon: <Download />,
onSelect: ({ rows: picked }) => say(`Exported ${picked.length} order${picked.length === 1 ? "" : "s"}`),
},
{
id: "delete-many",
label: "Delete selected",
icon: <Trash2 />,
variant: "destructive",
onSelect: ({ rows: picked }) => {
const ids = new Set(picked.map((r) => r.original.id))
setRows((prev) => prev.filter((r) => !ids.has(r.id)))
say(`Deleted ${ids.size} order${ids.size === 1 ? "" : "s"}`)
},
},
]
return (
<>
<div className="docs-demo__status" aria-live="polite">
<span>{log ?? "Open the ⋮ menu on a row, or select rows and use the one in the header"}</span>
<span>Delete is hidden on completed orders</span>
</div>
<ProGrid<OperationOrder>
columns={baseColumns.slice(0, 5)}
data={rows}
getRowId={(row) => row.id}
height={360}
rowActions={{ items, bulkItems }}
title="Fulfillment orders"
/>
</>
)
}// Actions are the host's; the grid renders the trigger and calls back.
// `items` takes the row, so a menu can vary per record.
import type { ReactNode } from "react"
import type { Row, Table } from "@tanstack/react-table"
/**
* How an action reads.
*
* Styling only. `destructive` does not imply a confirmation step — what needs
* confirming, and how, belongs to the host's design system, not to a grid.
*/
type RowActionVariant = "default" | "primary" | "destructive" | "warning"
/** What an action is acting on when it runs. */
type RowActionContext<T> = {
/** The row the menu was opened from. Absent for a bulk (header) action. */
row?: Row<T>
/** One row for a row action; every selected row for a bulk action. */
rows: Row<T>[]
table: Table<T>
}
type RowAction<T> = {
/** Stable key, and what distinguishes this item in a shared handler. */
id: string
label: ReactNode
icon?: ReactNode
variant?: RowActionVariant
disabled?: boolean
/** Dropped from the menu entirely, rather than shown greyed out. */
hidden?: boolean
onSelect: (ctx: RowActionContext<T>) => void
}
/** Handed to `renderCell`: the resolved items, plus the runner that binds them. */
type RowActionsCellContext<T> = {
row: Row<T>
/** Already resolved — function form called, `hidden` dropped, ids deduped. */
items: RowAction<T>[]
/** Runs an item against this row, assembling its `RowActionContext`. */
run: (item: RowAction<T>) => void
table: Table<T>
}
/** Handed to `renderHeader`, against the current selection. */
type RowActionsHeaderContext<T> = {
rows: Row<T>[]
items: RowAction<T>[]
run: (item: RowAction<T>) => void
table: Table<T>
}
type RowActionsConfig<T> = {
/**
* `"leading"` shares the grid's existing checkbox/chevron column, so the
* actions cost no extra gutter. `"trailing"` gives them their own column,
* pinned to the right edge.
*/
position?: "leading" | "trailing"
/** The per-row items. The function form is evaluated per row, per render. */
items?: RowAction<T>[] | ((row: Row<T>) => RowAction<T>[])
/**
* Items for the header menu, run against the selection. Defaults to `items`
* when that is an array; a function `items` takes one row and so has nothing
* to be called with here. Pass `[]` for no header affordance.
*/
bulkItems?: RowAction<T>[] | ((rows: Row<T>[]) => RowAction<T>[])
/**
* Replaces the whole cell — a plain button, your own dropdown, a dialog
* trigger. The resolved `items` and a `run` come with it, so the config stays
* the single source of truth even when the chrome is yours.
*/
renderCell?: (ctx: RowActionsCellContext<T>) => ReactNode
/** Replaces the header affordance, on the same bargain. */
renderHeader?: (ctx: RowActionsHeaderContext<T>) => ReactNode
/** Width of the trailing column, or the width the actions add to the lead one. */
width?: number
/** Suppresses the trigger per row. Group and aggregate rows are always out. */
isRowActionable?: (row: Row<T>) => boolean
/** `aria-label` for the built-in trigger. Defaults to the localized string. */
triggerLabel?: string
}
// Delete withholds itself from an order that has already shipped:
hidden: row.original.status === "Complete"
// The header's menu runs the same verbs over `table.getSelectedRowModel().rows`.Fulfillment orders
Clipboard
Copy serializes the range as tab-separated text, formatted the way the cells display it, so it pastes straight into a spreadsheet. Cells containing a tab, line break or quote are quoted. The context menu offers the same copy with the header row, and, while rows are grouped, laid out under their group summaries.