Data Grid

A spreadsheet-like grid for editing records, with typed columns, sorting and grouping.

IssueStatusPriorityAssigneeLabelsEstimateDueImpact
1ENG-142Sign-in link expires before the email arrivesIn ProgressUrgentALAda LovelaceBug3Dec 4★★★
2ENG-139Keyboard shortcuts for triageTodoHighGHGrace HopperFeature5Dec 11★★★
3ENG-137Export drops the last row of a filtered viewIn ReviewHighATAlan TuringBug2Dec 3★★★
4ENG-135Draft release notes for 2.4In ProgressMediumScout1Dec 6★★★
5ENG-131Empty states for saved viewsTodoMediumALAda LovelaceDesign3★★★
6ENG-128Notifications arrive twice on mobileTodoLowBug★★★
7ENG-126Bulk move issues between teamsIn ReviewMediumGHGrace HopperFeature8Dec 9★★★
8ENG-121Webhook retries with backoffDoneHighATAlan TuringFeature5Nov 27★★★
9ENG-118Dark mode contrast on badgesDoneLowALAda LovelaceDesign1Nov 24★★★
10ENG-144Invoice PDF cuts off long company namesTodoUrgentGHGrace HopperBug2Dec 2★★★
11ENG-140SAML sign-in for the admin consoleIn ProgressHighATAlan TuringFeature8Dec 18★★★
12ENG-133Triage suggestions for new bug reportsIn ReviewMediumScoutFeature3Dec 10★★★
12 rows
ReturnF2
Edit the cell, or type to replace it; Escape cancels and Tab saves and moves
Shift Down arrowShift Right arrow
Stretch a range of cells; Shift+click or drag does too
Command CCommand V
Copy or paste cells as tab-separated text; one value pasted fills the range
Command D
Fill down from the range's top row, or from the row above
Forward delete
Clear the cell or the range
Command ZCommand Shift Z
Undo or redo your last change
Option Shift Right arrow
Move a column, on its header
JDown arrow
Next record
KUp arrow
Previous record
Shift JShift K
Extend the selection
X
Select or unselect
Space
Peek at the record; Escape closes it
Return
Open the record
S
Change Status on the focused or selected records
P
Change Priority on the focused or selected records
A
Change Assignee on the focused or selected records
Escape
Clear the selection

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/table

Usage

import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { type Item, type Property, View } from "./ui/uicontext/components/domain/Record.ts"import { Table } from "./ui/uicontext/components/kit/Table.ts"import { Value } from "./ui/uicontext/components/kit/Property.ts"
const Message = UiSchema.TaggedEnum({	RequestedEditTask: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },	ChangedTaskView: { view: View },})interface Model {	readonly tasks: ReadonlyArray<Item>	readonly fields: ReadonlyArray<Property>	readonly view: View	readonly outcomes: ReadonlyArray<Outcome>}export const Tasks = (h: Html.H<typeof Message.Type>, { tasks, fields, view, outcomes }: Model) =>	Table(h, {		props: { label: "Tasks", records: tasks, fields, view, title: { label: "Task", editable: true }, outcomes },		onEmit: {			// save the edit, then answer with { _tag: "Accepted" | "Refused", request } in `outcomes`			RequestedEdit: (edit) => Message.RequestedEditTask(edit),			// sorting, resizing and hiding columns come back as the next view			RequestedView: ({ view }) => Message.ChangedTaskView({ view }),			RequestedOpen: () => undefined,			RequestedCreate: () => undefined,			RequestedAction: () => undefined,			RequestedReorder: () => undefined,			RequestedCellAction: () => undefined,			RequestedAddColumn: () => undefined,			RequestedColumnAction: () => undefined,			Selected: () => undefined,		},	})

Examples

Editing

Edits are requests the app accepts or refuses. This one refuses estimates over 8 and closing an unassigned issue.

IssueStatusPriorityAssigneeEstimate
1ENG-135Draft release notes for 2.4In ProgressMediumScout1
2ENG-131Empty states for saved viewsTodoMediumALAda Lovelace3
3ENG-128Notifications arrive twice on mobileTodoLow
4ENG-126Bulk move issues between teamsIn ReviewMediumGHGrace Hopper8
5ENG-121Webhook retries with backoffDoneHighATAlan Turing5
5 rows

Estimates above 8, and closing an unassigned issue, are refused in this example.

Grouping

Rows grouped by priority, sorted by due date within each group. Click a group's header to fold it.

IssueStatusAssigneeLabelsEstimateDue
Urgent2
1ENG-144Invoice PDF cuts off long company namesTodoGHGrace HopperBug2Dec 2
2ENG-142Sign-in link expires before the email arrivesIn ProgressALAda LovelaceBug3Dec 4
High4
1ENG-121Webhook retries with backoffDoneATAlan TuringFeature5Nov 27
2ENG-137Export drops the last row of a filtered viewIn ReviewATAlan TuringBug2Dec 3
3ENG-139Keyboard shortcuts for triageTodoGHGrace HopperFeature5Dec 11
4ENG-140SAML sign-in for the admin consoleIn ProgressATAlan TuringFeature8Dec 18
Medium4
1ENG-135Draft release notes for 2.4In ProgressScout1Dec 6
2ENG-126Bulk move issues between teamsIn ReviewGHGrace HopperFeature8Dec 9
3ENG-133Triage suggestions for new bug reportsIn ReviewScoutFeature3Dec 10
4ENG-131Empty states for saved viewsTodoALAda LovelaceDesign3
Low2
1ENG-118Dark mode contrast on badgesDoneALAda LovelaceDesign1Nov 24
2ENG-128Notifications arrive twice on mobileTodoBug
12 rows· This example only groups and sorts.

Frozen and moved columns

The title and Status stay in place while the rest scroll. Freeze from a column's menu, drag a header to move it, or drag its edge to resize it.

IssueStatusPriorityAssigneeLabelsEstimateDueCustomerImpact
1ENG-142Sign-in link expires before the email arrivesIn ProgressUrgentALAda LovelaceBug3Dec 4Northwind Freight★★★
2ENG-139Keyboard shortcuts for triageTodoHighGHGrace HopperFeature5Dec 11★★★
3ENG-137Export drops the last row of a filtered viewIn ReviewHighATAlan TuringBug2Dec 3Halcyon Health★★★
4ENG-135Draft release notes for 2.4In ProgressMediumScout1Dec 6★★★
5ENG-131Empty states for saved viewsTodoMediumALAda LovelaceDesign3★★★
6ENG-128Notifications arrive twice on mobileTodoLowBugBluebird Credit Union★★★
7ENG-126Bulk move issues between teamsIn ReviewMediumGHGrace HopperFeature8Dec 9Northwind Freight★★★
8ENG-121Webhook retries with backoffDoneHighATAlan TuringFeature5Nov 27Halcyon Health★★★
9ENG-118Dark mode contrast on badgesDoneLowALAda LovelaceDesign1Nov 24★★★
10ENG-144Invoice PDF cuts off long company namesTodoUrgentGHGrace HopperBug2Dec 2Bluebird Credit Union★★★
11ENG-140SAML sign-in for the admin consoleIn ProgressHighATAlan TuringFeature8Dec 18Halcyon Health★★★
12ENG-133Triage suggestions for new bug reportsIn ReviewMediumScoutFeature3Dec 10★★★
12 rows· This example only arranges columns.

A CRM base

Companies with typed columns: links, currency, ratings and people.

CompanyStageOwnerARRWin probabilityFitWebsiteBilling emailPhoneContractsPrimary contactOpen dealsARR per seat
1Northwind FreightCustomerMCMaya Chen$184,000100%★★★★★northwind.example[email protected]+1 415 555 0142northwind-msa.pdfPriya Raman2$460
2Halcyon HealthTrialOHOmar Haddad$065%★★★★★halcyon.example[email protected]+1 617 555 0199Jonas Berg1#ERROR
3Bluebird Credit UnionCustomerLFLena Fischer$96,000100%★★★★★bluebird.example[email protected]+1 312 555 0110bluebird-order-form.pdfbluebird-dpa.pdfSofia Alvarez0$320
4Orchard RoboticsLeadMCMaya Chen$020%★★★★★orchard.exampleKenji Watanabe1$0
5Lumen SchoolsTrialOHOmar Haddad$42,00045%★★★★★lumen.example[email protected]+44 20 7946 0321Amara Okafor3$140
6Kestrel LogisticsChurnedLFLena Fischer$00%★★★★★kestrel.example[email protected]+1 206 555 0187kestrel-msa.pdfTom Hughes0$0
6 rows

Try lowering Northwind Freight's ARR: the app refuses, the old value comes back and a toast says why.

Five thousand rows

Only the rows near the visible part are drawn, so scrolling, sorting and editing stay quick.

IssueStatusPriorityAssigneeEstimateDueImpact
1ENG-5000Billing times out for large workspacesTodoUrgentALAda LovelaceJan 1★★★
2ENG-4748Notifications ignores the saved filterTodoUrgentATAlan TuringJan 1★★★
3ENG-4496Billing times out for large workspacesTodoUrgentJan 1★★★
4ENG-4244Notifications ignores the saved filterTodoUrgentGHGrace HopperJan 1★★★
5ENG-3992Billing times out for large workspacesTodoUrgentScoutJan 1★★★
6ENG-3740Notifications ignores the saved filterTodoUrgentALAda LovelaceJan 1★★★
7ENG-3488Billing times out for large workspacesTodoUrgentATAlan TuringJan 1★★★
8ENG-3236Notifications ignores the saved filterTodoUrgentJan 1★★★
9ENG-2984Billing times out for large workspacesTodoUrgentGHGrace HopperJan 1★★★
10ENG-2732Notifications ignores the saved filterTodoUrgentScoutJan 1★★★
11ENG-2480Billing times out for large workspacesTodoUrgentALAda LovelaceJan 1★★★
12ENG-2228Notifications ignores the saved filterTodoUrgentATAlan TuringJan 1★★★
13ENG-1976Billing times out for large workspacesTodoUrgentJan 1★★★
14ENG-1724Notifications ignores the saved filterTodoUrgentGHGrace HopperJan 1★★★
15ENG-1472Billing times out for large workspacesTodoUrgentScoutJan 1★★★
16ENG-1220Notifications ignores the saved filterTodoUrgentALAda LovelaceJan 1★★★
17ENG-968Billing times out for large workspacesTodoUrgentATAlan TuringJan 1★★★
18ENG-716Notifications ignores the saved filterTodoUrgentJan 1★★★
19ENG-464Billing times out for large workspacesTodoUrgentGHGrace HopperJan 1★★★
20ENG-212Notifications ignores the saved filterTodoUrgentScoutJan 1★★★
21ENG-4775Sign-in sends a duplicate emailDoneUrgentALAda LovelaceJan 2★★★
22ENG-4523Admin console needs an empty stateDoneUrgentATAlan TuringJan 2★★★
23ENG-4271Sign-in sends a duplicate emailDoneUrgentJan 2★★★
24ENG-4019Admin console needs an empty stateDoneUrgentGHGrace HopperJan 2★★★
25ENG-3767Sign-in sends a duplicate emailDoneUrgentScoutJan 2★★★
26ENG-3515Admin console needs an empty stateDoneUrgentALAda LovelaceJan 2★★★
27ENG-3263Sign-in sends a duplicate emailDoneUrgentATAlan TuringJan 2★★★
28ENG-3011Admin console needs an empty stateDoneUrgentJan 2★★★
29ENG-2759Sign-in sends a duplicate emailDoneUrgentGHGrace HopperJan 2★★★
30ENG-2507Admin console needs an empty stateDoneUrgentScoutJan 2★★★
31ENG-2255Sign-in sends a duplicate emailDoneUrgentALAda LovelaceJan 2★★★
32ENG-2003Admin console needs an empty stateDoneUrgentATAlan TuringJan 2★★★
33ENG-1751Sign-in sends a duplicate emailDoneUrgentJan 2★★★
34ENG-1499Admin console needs an empty stateDoneUrgentGHGrace HopperJan 2★★★
35ENG-1247Sign-in sends a duplicate emailDoneUrgentScoutJan 2★★★
36ENG-995Admin console needs an empty stateDoneUrgentALAda LovelaceJan 2★★★
37ENG-743Sign-in sends a duplicate emailDoneUrgentATAlan TuringJan 2★★★
38ENG-491Admin console needs an empty stateDoneUrgentJan 2★★★
39ENG-239Sign-in sends a duplicate emailDoneUrgentGHGrace HopperJan 2★★★
40ENG-4802Mobile app loses the draft on reloadIn ReviewUrgentScoutJan 3★★★
5,000 rows

API reference

Props

Table props
NameTypeDefaultDescription
labelrequiredstring—The table's accessible name: "Tasks"
agentIdstringtable:<label>This table's id for agents, unique on the page; table:<label> by default
recordsrequiredItem[]—The records to show, in the order the app gives them
fieldsrequiredProperty[]—Every field, in its own order; the view hides and orders them
viewViewInput—How the records show: sort, groupBy, hidden, order, widths and filter
title{ label, width, editable }—The first, frozen column: the record's title. editable makes it a text cell
shortcutsFieldShortcut[]—Single keys that open a field's picker on the focused or selected rows: { key: "s", field: "stage" }
selectablebooleantrueA checkbox per row and the action bar; true by default
actionsItemAction[]—Actions offered on each record, such as archive or delete
createstring—An "add row" button with this label, emitting RequestedCreate; absent hides it (a synced table)
openableboolean—Each row gets an open button, and Enter on a read-only title opens it
resizableboolean—Column edges can be dragged, or moved with Alt+Arrow keys on a header; each asks for a new view
addColumnstring—A "+" header after the last column, emitting RequestedAddColumn: its label, "Add a field"
columnActionsItemAction[]—A menu on each header ("Edit field", "Delete field"), emitting RequestedColumnAction
hideableboolean—A "Hide field" entry in each field's column menu, asking for a view with the field hidden
freezableboolean—A "Freeze up to here" entry in each field's column menu, asking for a view with frozen set
movableboolean—Field headers can be dragged to a new place, or moved with Alt+Shift+Arrow keys; each asks for a new view
readOnlystring—Why nothing here can be edited: "You can view this table, not edit it"
loadingboolean—Show placeholder rows while the records load
empty{ title, hint }—What the grid says when there are no records: a title and a hint
outcomesOutcome[]—How each requested change settled: pending, accepted, or refused with a reason
noticestring | null—A sentence about the last bulk action or a table-level refusal
rowHeightnumber32A row's height in pixels; 32 by default
localestring—The locale numbers and dates are formatted in; the browser's by default

Events

Table events
EventPayloadDescription
RequestedEdit{ request: string; item: string; key: string; value: Value }A value the person changed; answer through outcomes with the same request
RequestedOpen{ item: string }Open the record's page
RequestedCreate{ group?: string; title?: string; values?: Record<string, Value> }A new record, in the group it was added from ("" for the empty group)
RequestedAction{ action: string; items: string[] }One of the view's actions, on these records
RequestedReorder{ item: string; before: string | null }Move item before before, or last when it's null
RequestedView{ view: View }The person changed how the view shows records (its sort, grouping, widths); pass it back as view
Selected{ items: string[] }The selection changed
RequestedCellAction{ item: string; key: string; action: string }A cell's button: "Run agent", "Retry", a button field's press
RequestedAddColumn{}The "+" header was pressed: open a field editor to add a field
RequestedColumnAction{ key: string; action: string }One of columnActions on a column (title for the first)

Agent actions

What agents can do with Table
ActionDescription
CommittedEditSet one cell. key: a column key (or title when it's editable). value: an option value, a list of them, text, a number, an ISO date, true/false, or null to clear
ClickedCellActionPress a cell's button, such as Run agent or Retry (see the cell's action in the page)
RequestedSelectionSelect rows by id, replacing the selection ([] clears it)
ClickedActionRun one of the table's actions on the selected rows; destructive ones name the selection as the target
ClickedSortOrder the rows by a column key (or title), asc or desc, replacing the view's sort; direction null drops it
ActivatedRowOpen a row
ClickedCreateAdd a row
ClickedAddColumnStart adding a column
ClickedColumnActionRun one of a column's actions (key: a column key, or title); destructive ones name the column
ClickedHideColumnHide a field's column from this view (key: a field key)
ClickedPeekShow a row's fields in Peek, beside the grid
ClosedPeekClose Peek

Wiring it to your app

The grid handles the active cell, selection and showing an edit before it saves. Handle RequestedEdit with an app command, and reply through outcomes with the request's ID.

On success, pass the saved row with an Accepted outcome. On refusal, pass a Refused outcome with the reason and leave the row unchanged. Edits from people and agents can share the same command and rules.

View a complete app example
import { Command, UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import { Effect, Schema } from "effect"import { Outcome, type Property, Value } from "./ui/uicontext/components/kit/Property.ts"import { Table } from "./ui/uicontext/components/kit/Table.ts"const Status = Schema.Literals(["Ready", "Paused"])const isStatus = Schema.is(Status)const Workflow = Schema.Struct({ id: Schema.String, name: Schema.String, status: Status })const Edit = { request: Schema.String, item: Schema.String, key: Schema.String, value: Value }const SaveResult = Schema.Union([	Schema.TaggedStruct("Saved", { status: Status }),	Schema.TaggedStruct("Refused", { reason: Schema.String }),])export class SaveWorkflow extends Command.Service<SaveWorkflow>()("recipe/SaveWorkflow", {	args: Edit,	success: SaveResult,	mode: "queue",	group: ["item"],}) {	static readonly layer = this.toLayer(({ item, key, value }) =>		Effect.sleep("350 millis").pipe(Effect.map(() => {			if (key !== "status" || !isStatus(value)) {				return { _tag: "Refused", reason: "Enter Ready or Paused." }			}			if (item === "billing" && value === "Paused") {				return { _tag: "Refused", reason: "Billing sync must stay ready." }			}			return { _tag: "Saved", status: value }		})),	)}const Message = UiSchema.TaggedEnum({	RequestedEdit: Edit,	SavedEdit: { request: Schema.String, item: Schema.String, result: SaveResult },	RequestedArchive: { items: Schema.Array(Schema.String) },})const properties: ReadonlyArray<Property> = [{ key: "status", label: "Status", kind: "text" }]const archive = [{ id: "archive", label: "Archive selected", consequential: true }] as constexport const Workflows = Html.component({	name: "WorkflowStatus",	model: Schema.Struct({		workflows: Schema.Array(Workflow),		pending: Schema.Array(Schema.String),		outcomes: Schema.Array(Outcome),		notice: Schema.String,	}),	message: Message,}).make({	init: () => ({		workflows: [			{ id: "digest", name: "Daily digest", status: "Ready" },			{ id: "billing", name: "Billing sync", status: "Ready" },		],		pending: [],		outcomes: [],		notice: "Changes are kept until you reload this page.",	}),	update: {		RequestedEdit: ($, { request, item, key, value }) =>			$.evolve({ pending: (pending) => [...pending, request] })				.run(Command.map(					SaveWorkflow.make({ request, item, key, value }),					(result) => Message.SavedEdit({ request, item, result }),				)),		SavedEdit: ($, { request, item, result }) => {			if (!$.model.pending.includes(request)) return $.model			const saved = result._tag === "Saved"			return $.evolve({				workflows: saved					? $.model.workflows.map((workflow) => workflow.id === item ? { ...workflow, status: result.status } : workflow)					: $.model.workflows,				pending: (pending) => pending.filter((id) => id !== request),				outcomes: (outcomes) => [...outcomes, saved ? { _tag: "Accepted" as const, request } : { _tag: "Refused" as const, request, reason: result.reason }],				notice: saved ? "Status saved." : "Status left unchanged.",			})		},		RequestedArchive: ($, { items }) => {			if ($.model.pending.length !== 0) return $.model			return $.evolve({				workflows: (workflows) => workflows.filter(({ id }) => !items.includes(id)),				notice: "Selection archived.",			})		},	},	view: (h, model) => {		const items = model.workflows.map(({ id, name, status }) => ({ id, title: name, values: { status } }))		return h.section.attr("aria-labelledby", "workflow-heading").children(			h.header.children(				h.h2.attr("id", "workflow-heading").children("Workflow status"),				h.p.children("Press Enter on a status to edit it. Try pausing Billing sync to see a refused save."),			),			h.div.attr("class", "table").children(				Table(h, {					key: "workflows",					props: {						agentId: "workflows",						label: "Workflows",						title: { label: "Workflow", width: 176 },						view: { widths: { status: 160 } },						rowHeight: 40,						records: items,						fields: properties,						outcomes: model.outcomes,						actions: model.pending.length === 0 ? archive : [],					},					onEmit: {						RequestedEdit: (edit) => Message.RequestedEdit(edit),						RequestedAction: ({ action, items }) => action === "archive" ? Message.RequestedArchive({ items }) : undefined,						RequestedOpen: () => undefined,						RequestedCreate: () => undefined,						RequestedReorder: () => undefined,						RequestedView: () => undefined,						RequestedCellAction: () => undefined,						RequestedAddColumn: () => undefined,						RequestedColumnAction: () => undefined,						Selected: () => undefined,					},				}),			),			h.p.attrs({ class: "feedback", role: "status" }).children(				model.pending.length > 0 ? "Saving changes…" : model.notice,			),		)	},})
workflows.ts on GitHub

Accessibility

  • A grid: arrow keys move between cells and headers, Enter or F2 edits, typing starts an edit, Escape cancels, Tab saves and moves on.
  • Mod+C copies the selected cells, and pasting tab-separated text fills a block.
  • Shift+F10 on a header opens its column actions; Alt+Left and Alt+Right resize a column.
  • A refused edit puts the old value back and says why.
  • A cell that can't be edited is read-only, and says why as its description and in a tip under it while it has focus, by keyboard or touch.

Source