# Record List

> Rows of records, grouped and sorted, that you edit in place.

Page: https://uicontext.com/docs/components/record-list

Group: Records.

## When to use

Rows of records, grouped and sorted, that you edit in place. Use [Data Grid](https://uicontext.com/docs/components/data-grid.md) instead when the rows have many columns to compare.

## Usage

```ts
import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"
import { type Item, type Property, Value } from "./ui/uicontext/components/domain/Record.ts"
import { RecordList } from "./ui/uicontext/components/RecordList.ts"

const Message = UiSchema.TaggedEnum({
	RequestedEditTask: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },
	OpenedTask: { id: Schema.String },
})

export const TaskList = (
	h: Html.H<typeof Message.Type>,
	tasks: ReadonlyArray<Item>,
	fields: ReadonlyArray<Property>,
	outcomes: ReadonlyArray<Outcome>,
) =>
	RecordList(h, {
		props: {
			label: "Tasks",
			records: tasks,
			fields,
			view: { groupBy: "status" },
			columns: [{ key: "status", at: "start", compact: true }, { key: "assignee", compact: true }],
			outcomes,
		},
		onEmit: {
			RequestedEdit: (edit) => Message.RequestedEditTask(edit),
			RequestedOpen: ({ item }) => Message.OpenedTask({ id: item }),
			RequestedView: () => undefined,
			RequestedAction: () => undefined,
			RequestedReorder: () => undefined,
			RequestedCreate: () => undefined,
			Selected: () => undefined,
		},
	})
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### Grouped

The example the page opens with: Record List in “Grouped”.

```ts title="src/demo.ts" source="www/src/examples/record-list/demo.ts"
import { UiSchema } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"
import { View, viewOf } from "./ui/uicontext/components/domain/Record.ts"
import { RecordList } from "./ui/uicontext/components/RecordList.ts"
import { Item, Value } from "./ui/uicontext/components/Property.ts"
import { collectionKeymap, KeymapLegend } from "./ui/uicontext/components/RecordKeys.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { applyEdit, issueFields, issues, issueShortcuts } from "./issues.ts"

const styles = stylex.create({
	stack: { display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: 20 },
	frame: { blockSize: 420, inlineSize: "100%" },
})

const Message = UiSchema.TaggedEnum({
	RequestedEditIssue: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },
	RequestedIssueAction: { action: Schema.String, items: Schema.Array(Schema.String) },
	RequestedIssueView: { view: View },
})

export const IssueList = Html.component({
	name: "IssueList",
	model: Schema.Struct({ records: Schema.Array(Item), outcomes: Schema.Array(Outcome), view: View }),
	message: Message,
}).make({
	init: () => ({ records: issues, outcomes: [], view: viewOf({ groupBy: "status", sort: [{ key: "priority", direction: "asc" }] }, "list") }),
	update: {
		RequestedEditIssue: ($, { request, item, key, value }) =>
			$.evolve({
				records: (records) => records.map((r) => (r.id === item ? applyEdit(r, key, value) : r)),
				outcomes: (outcomes) => [...outcomes.slice(-10), { _tag: "Accepted", request }],
			}),
		RequestedIssueAction: ($, { action, items }) =>
			action === "archive" ? $.evolve({ records: (all) => all.filter((r) => !items.includes(r.id)) }) : $.model,
		RequestedIssueView: ($, { view }) => $.evolve({ view }),
	},
	view: (h, { records, outcomes, view }) =>
		h.div.attrs(sx(styles.stack)).children(
			h.div.attrs(sx(styles.frame)).children(
				RecordList(h, {
					props: {
						label: "Issues",
						records,
						fields: issueFields,
						view,
						columns: [
							{ key: "priority", at: "start", compact: true },
							{ key: "status", at: "start", compact: true },
							{ key: "labels" },
							{ key: "impact" },
							{ key: "due" },
							{ key: "assignee", compact: true },
						],
						// j/k move, x selects, Space peeks, Enter opens; s, p and a open these pickers
						shortcuts: issueShortcuts,
						actions: [
							{ id: "archive", label: "Archive" },
							{ id: "trash", label: "Delete", tone: "danger", consequential: true },
						],
						empty: { title: "No issues", hint: "Issues you create show up here." },
						outcomes,
					},
					onEmit: {
						RequestedEdit: (edit) => Message.RequestedEditIssue(edit),
						RequestedAction: ({ action, items }) => Message.RequestedIssueAction({ action, items }),
						RequestedView: ({ view }) => Message.RequestedIssueView({ view }),
						RequestedOpen: () => undefined,
						RequestedReorder: () => undefined,
						RequestedCreate: () => undefined,
						Selected: () => undefined,
					},
				}),
			),
			KeymapLegend(h, collectionKeymap(issueShortcuts), "List keyboard shortcuts"),
		),
})
```

### Ordered by hand

A flat list people put in order. Drag a row, or press Alt+Up and Alt+Down on it.

```ts title="src/ordered.ts" source="www/src/examples/record-list/ordered.ts"
import { UiSchema } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { RecordList } from "./ui/uicontext/components/RecordList.ts"
import { Item } from "./ui/uicontext/components/Property.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { issueFields, issues } from "./issues.ts"

// A flat list in an order people set by hand: drag a row, or press Alt+Up and Alt+Down on it. Each
// move asks with RequestedReorder; the app keeps the order.

const styles = stylex.create({
	frame: { blockSize: 320, inlineSize: "100%" },
})

const Message = UiSchema.TaggedEnum({
	RequestedMove: { item: Schema.String, before: Schema.NullOr(Schema.String) },
})

const move = (records: ReadonlyArray<Item>, item: string, before: string | null): ReadonlyArray<Item> => {
	const moving = records.find((r) => r.id === item)
	if (moving === undefined) return records
	const rest = records.filter((r) => r.id !== item)
	const at = before === null ? rest.length : rest.findIndex((r) => r.id === before)
	return [...rest.slice(0, at), moving, ...rest.slice(at)]
}

export const PlannedList = Html.component({
	name: "PlannedList",
	model: Schema.Struct({ records: Schema.Array(Item) }),
	message: Message,
}).make({
	init: () => ({ records: issues.filter((issue) => issue.values["status"] === "todo") }),
	update: {
		RequestedMove: ($, { item, before }) => $.evolve({ records: (records) => move(records, item, before) }),
	},
	view: (h, { records }) =>
		h.div.attrs(sx(styles.frame)).children(
			RecordList(h, {
				props: {
					label: "Next up",
					records,
					fields: issueFields,
					columns: [{ key: "priority", at: "start", compact: true }, { key: "estimate" }, { key: "assignee", compact: true }],
					reorderable: true,
					selectable: false,
				},
				onEmit: {
					RequestedReorder: ({ item, before }) => Message.RequestedMove({ item, before }),
					RequestedEdit: () => undefined,
					RequestedOpen: () => undefined,
					RequestedView: () => undefined,
					RequestedAction: () => undefined,
					RequestedCreate: () => undefined,
					Selected: () => undefined,
				},
			}),
		),
})
```

### Empty

What a list says before it has records, with a button for the first one.

```ts title="src/empty.ts" source="www/src/examples/record-list/empty.ts"
import { UiSchema } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { RecordList } from "./ui/uicontext/components/RecordList.ts"
import { Item } from "./ui/uicontext/components/Property.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { issueFields } from "./issues.ts"

// With no records, the list shows its empty state, and `empty.create` offers the first one.

const styles = stylex.create({
	frame: { blockSize: 280, inlineSize: "100%" },
})

const Message = UiSchema.TaggedEnum({ RequestedNewIssue: {} })

export const EmptyList = Html.component({
	name: "EmptyList",
	model: Schema.Struct({ records: Schema.Array(Item) }),
	message: Message,
}).make({
	init: () => ({ records: [] }),
	update: {
		RequestedNewIssue: ($) =>
			$.evolve({
				records: (records) => [
					...records,
					{ id: `eng-${150 + records.length}`, prefix: `ENG-${150 + records.length}`, title: "Untitled issue", values: { status: "todo" } },
				],
			}),
	},
	view: (h, { records }) =>
		h.div.attrs(sx(styles.frame)).children(
			RecordList(h, {
				props: {
					label: "Mobile app issues",
					records,
					fields: issueFields,
					columns: [{ key: "status", at: "start", compact: true }],
					empty: { title: "No issues yet", hint: "Issues for the mobile app show up here.", create: "New issue" },
				},
				onEmit: {
					RequestedCreate: () => Message.RequestedNewIssue(),
					RequestedEdit: () => undefined,
					RequestedOpen: () => undefined,
					RequestedView: () => undefined,
					RequestedAction: () => undefined,
					RequestedReorder: () => undefined,
					Selected: () => undefined,
				},
			}),
		),
})
```

### Sample data

The examples above import these files.

```ts title="src/issues.ts" source="www/src/examples/_shared/issues.ts"
import type { Item, Property } from "./ui/uicontext/components/Property.ts"
import { color } from "./ui/uicontext/components/tokens.stylex.ts"

// One set of issues for every record view: the list, the board, the data grid, the form and the
// detail all take the same `records` and `fields` (and a `view`), so switching views is switching
// components.

export const people = [
	{ value: "ada", label: "Ada Lovelace", glyph: { _tag: "Person" as const, id: "ada", name: "Ada Lovelace", agent: false } },
	{ value: "grace", label: "Grace Hopper", glyph: { _tag: "Person" as const, id: "grace", name: "Grace Hopper", agent: false } },
	{ value: "alan", label: "Alan Turing", glyph: { _tag: "Person" as const, id: "alan", name: "Alan Turing", agent: false } },
	{ value: "scout", label: "Scout", glyph: { _tag: "Person" as const, id: "scout", name: "Scout", agent: true } },
]

// a relation's options are the records it can link to, with their titles
export const customers = [
	{ value: "northwind", label: "Northwind Freight" },
	{ value: "halcyon", label: "Halcyon Health" },
	{ value: "bluebird", label: "Bluebird Credit Union" },
]

export const issueFields: ReadonlyArray<Property> = [
	{
		key: "status",
		label: "Status",
		kind: "select",
		options: [
			{ value: "todo", label: "Todo", glyph: { _tag: "Ring", color: color.muted, progress: 0, label: "Todo" } },
			{ value: "doing", label: "In Progress", glyph: { _tag: "Ring", color: color.caution, progress: 0.5, label: "In Progress" } },
			{ value: "review", label: "In Review", glyph: { _tag: "Ring", color: color.success, progress: 0.75, label: "In Review" } },
			{ value: "done", label: "Done", glyph: { _tag: "Ring", color: color.done, progress: 1, mark: "check", label: "Done" } },
		],
	},
	{
		key: "priority",
		label: "Priority",
		kind: "select",
		empty: "No priority",
		options: [
			{ value: "urgent", label: "Urgent", glyph: { _tag: "Bars", level: 3, alert: true, label: "Urgent" } },
			{ value: "high", label: "High", glyph: { _tag: "Bars", level: 3, label: "High" } },
			{ value: "medium", label: "Medium", glyph: { _tag: "Bars", level: 2, label: "Medium" } },
			{ value: "low", label: "Low", glyph: { _tag: "Bars", level: 1, label: "Low" } },
		],
	},
	{ key: "assignee", label: "Assignee", kind: "person", empty: "No assignee", options: people },
	{
		key: "labels",
		label: "Labels",
		kind: "multiSelect",
		options: [
			{ value: "bug", label: "Bug", glyph: { _tag: "Swatch", color: color.danger } },
			{ value: "feature", label: "Feature", glyph: { _tag: "Swatch", color: color.info } },
			{ value: "design", label: "Design", glyph: { _tag: "Swatch", color: color.agent } },
		],
	},
	{ key: "estimate", label: "Estimate", kind: "number", empty: "No estimate", description: "In points" },
	{ key: "due", label: "Due", kind: "date" },
	{
		key: "customer",
		label: "Customer",
		kind: "relation",
		relation: { target: "Companies", multiple: false },
		options: customers,
		empty: "No customer",
	},
	{ key: "impact", label: "Impact", kind: "rating", max: 3, description: "How much it matters to the customer" },
]

const issue = (n: number, title: string, values: Item["values"], extra: Partial<Item> = {}): Item => ({
	id: `eng-${n}`,
	prefix: `ENG-${n}`,
	title,
	values,
	...extra,
})

export const issues: ReadonlyArray<Item> = [
	issue(142, "Sign-in link expires before the email arrives", { status: "doing", priority: "urgent", assignee: "ada", labels: ["bug"], estimate: 3, due: "2026-12-04", customer: ["northwind"], impact: 3 }),
	issue(139, "Keyboard shortcuts for triage", { status: "todo", priority: "high", assignee: "grace", labels: ["feature"], estimate: 5, due: "2026-12-11", customer: [], impact: 2 }),
	issue(137, "Export drops the last row of a filtered view", { status: "review", priority: "high", assignee: "alan", labels: ["bug"], estimate: 2, due: "2026-12-03", customer: ["halcyon"], impact: 3 }),
	issue(135, "Draft release notes for 2.4", { status: "doing", priority: "medium", assignee: "scout", labels: [], estimate: 1, due: "2026-12-06", customer: [], impact: null }, { busy: "Scout is writing" }),
	issue(131, "Empty states for saved views", { status: "todo", priority: "medium", assignee: "ada", labels: ["design"], estimate: 3, due: null, customer: [], impact: 1 }),
	issue(128, "Notifications arrive twice on mobile", { status: "todo", priority: "low", assignee: null, labels: ["bug"], estimate: null, due: null, customer: ["bluebird"], impact: 2 }),
	issue(126, "Bulk move issues between teams", { status: "review", priority: "medium", assignee: "grace", labels: ["feature"], estimate: 8, due: "2026-12-09", customer: ["northwind"], impact: 2 }),
	issue(121, "Webhook retries with backoff", { status: "done", priority: "high", assignee: "alan", labels: ["feature"], estimate: 5, due: "2026-11-27", customer: ["halcyon"], impact: 1 }),
	issue(118, "Dark mode contrast on badges", { status: "done", priority: "low", assignee: "ada", labels: ["design"], estimate: 1, due: "2026-11-24", customer: [], impact: 1 }),
	issue(144, "Invoice PDF cuts off long company names", { status: "todo", priority: "urgent", assignee: "grace", labels: ["bug"], estimate: 2, due: "2026-12-02", customer: ["bluebird"], impact: 3 }, { attention: true, note: "Reported by three customers this week" }),
	issue(140, "SAML sign-in for the admin console", { status: "doing", priority: "high", assignee: "alan", labels: ["feature"], estimate: 8, due: "2026-12-18", customer: ["halcyon"], impact: 3 }),
	issue(133, "Triage suggestions for new bug reports", { status: "review", priority: "medium", assignee: "scout", labels: ["feature"], estimate: 3, due: "2026-12-10", customer: [], impact: 2 }),
]

/** Single keys that open a field's picker on the focused (or every selected) issue. */
export const issueShortcuts = [
	{ key: "s", field: "status", label: "Status" },
	{ key: "p", field: "priority", label: "Priority" },
	{ key: "a", field: "assignee", label: "Assignee" },
]

/** Applies an accepted edit to a record: the title, or one of its values. */
export const applyEdit = (record: Item, key: string, value: Item["values"][string]): Item =>
	key === "title" ? { ...record, title: String(value) } : { ...record, values: { ...record.values, [key]: value } }
```

## API reference

**Props**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `string` | — | The list's accessible name: "Issues" |
| `agentId` | `string` | `list:<label>` | This list's id for agents, unique on the page; `list:<label>` by default |
| `records` (required) | `Item[]` | — | The records to show, in the order the app gives them |
| `fields` (required) | `Property[]` | — | The fields the records share: their kinds, choices and formats |
| `view` | `ViewInput` | — | How the records show: its filter, sort, groupBy, hidden and order |
| `columns` | `RecordListColumn[]` | — | Where each shown field sits in a row; every shown field, after the title, by default |
| `shortcuts` | `FieldShortcut[]` | — | Single keys that open a field's picker on the focused or selected rows: `{ key: "s", field: "status" }` |
| `selectable` | `boolean` | `true` | Shows a checkbox per row and the action bar; true by default |
| `actions` | `ItemAction[]` | — | What the action bar offers for the selected rows |
| `reorderable` | `boolean` | — | Rows can be moved with Alt+Arrow keys or dragged, for a manually ordered list |
| `create` | `string` | — | Names a group header's + button ("New issue"), which emits `RequestedCreate` with the group; absent hides it |
| `loading` | `boolean` | — | Show placeholder rows while the records load |
| `empty` | `{ title, hint, create }` | — | The empty state; `create` adds a button that emits `RequestedCreate` |
| `outcomes` | `Outcome[]` | — | The app's answers to edit requests |
| `notice` | `string \| null` | — | A sentence about the last bulk action: "2 issues couldn't be archived: they're locked" |
| `rowHeight` | `number` | `40` | A row's height in pixels until measured; 40 by default |
| `locale` | `string` | — | For Intl formatting and sorting; the browser's language by default |
| `fresh` | `string[]` | — | Records the app just added, tinted until it takes them off the list |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `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 |

**Agent actions**

| Action | Description |
| --- | --- |
| `CommittedEdit` | Set one field of one row. value: an option value (see the field's choices), a list of them, text, a number, an ISO date, true/false, or null to clear |
| `RequestedSelection` | Select rows by id, replacing the selection ([] clears it) |
| `ClickedAction` | Run one of the list's actions on the selected rows; destructive ones name the selection as the target |
| `ActivatedRow` | Open a row, as Enter on it does |
| `ClickedPeek` | Peek at a row: its fields in a side sheet, without leaving the list |
| `ToggledGroup` | Collapse or expand a group by its value |
| `MovedRow` | Move a row before another (or to the end with before: null) |

## Keyboard and accessibility

### Keys

| Keys | Does |
| --- | --- |
| Left arrow, Right arrow | Move between a row’s cells; on a group, close or open it |
| Home, End | Go to the row’s first or last cell |
| Pageup, Pagedown | Move ten rows |
| Alt+Up arrow, Alt+Down arrow | Move the row in a list you can reorder |
| J, Down arrow | Next record |
| K, Up arrow | Previous record |
| Shift+J, Shift+K | Extend the selection |
| X | Select or unselect |
| Space | Peek at the record; Escape closes it |
| Enter | Open the record |
| Escape | Clear the selection |
| S, P, A | Open the picker for a field the app gives a shortcut, on the focused or selected records |

On a Mac, Control is Command and Alt is Option. Left and Right trade places in right-to-left text.

- A tree grid: arrows move between rows and cells, Enter edits or opens, Space or X selects, Shift extends the selection, Mod+A selects all.
- A locked cell, a refused edit or a note on a value shows its reason when the cell has focus or is tapped, and is read as the cell's description.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/record-list
```

With npm: `npx shadcn@latest add checkfu/uicontext/record-list`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/record-list`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/record-list`.

It writes these files:

- `src/ui/uicontext/components/Button.ts`
- `src/ui/uicontext/components/CellHint.ts`
- `src/ui/uicontext/components/CollectionFocus.ts`
- `src/ui/uicontext/components/Direction.ts`
- `src/ui/uicontext/components/Filter.ts`
- `src/ui/uicontext/components/FormControls.ts`
- `src/ui/uicontext/components/Glyph.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/InlineNotice.ts`
- `src/ui/uicontext/components/Kbd.ts`
- `src/ui/uicontext/components/Menu.ts`
- `src/ui/uicontext/components/Motion.ts`
- `src/ui/uicontext/components/Peek.ts`
- `src/ui/uicontext/components/Popover.ts`
- `src/ui/uicontext/components/Property.ts`
- `src/ui/uicontext/components/RecordKeys.ts`
- `src/ui/uicontext/components/RecordList.ts`
- `src/ui/uicontext/components/RequestNonce.ts`
- `src/ui/uicontext/components/SegmentedControl.ts`
- `src/ui/uicontext/components/Sheet.ts`
- `src/ui/uicontext/components/ShowText.ts`
- `src/ui/uicontext/components/Spoken.ts`
- `src/ui/uicontext/components/States.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/Toast.ts`
- `src/ui/uicontext/components/agent/Agent.ts`
- `src/ui/uicontext/components/button.stylex.ts`
- `src/ui/uicontext/components/collection.stylex.ts`
- `src/ui/uicontext/components/domain/Format.ts`
- `src/ui/uicontext/components/domain/Glyph.ts`
- `src/ui/uicontext/components/domain/Outcome.ts`
- `src/ui/uicontext/components/domain/Permission.ts`
- `src/ui/uicontext/components/domain/Record.ts`
- `src/ui/uicontext/components/hint.stylex.ts`
- `src/ui/uicontext/components/safeArea.stylex.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`
- `src/ui/uicontext/components/touch.stylex.ts`
- `src/ui/uicontext/components/variants.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/RecordList.ts](https://github.com/checkfu/uicontext/blob/main/src/RecordList.ts)

## Used in

- [Task manager](https://uicontext.com/blocks/issue-tracker.md)
- [Database](https://uicontext.com/blocks/tables.md)
- [Helpdesk](https://uicontext.com/blocks/helpdesk.md)

## Related

- [Data Grid](https://uicontext.com/docs/components/data-grid.md) (`data-grid`): A spreadsheet-like grid for editing records, with typed columns, sorting and grouping.
- [Pivot Table](https://uicontext.com/docs/components/pivot-table.md) (`pivot-table`): Records summed two ways, such as revenue by region and quarter, with totals on both edges and cells tinted by size.
- [Table](https://uicontext.com/docs/components/table.md) (`table`): A simple read-only table with a caption, row headers and an empty state.
- [Group Header](https://uicontext.com/docs/components/group-header.md) (`group-header`): The line over a group of rows with its count, sticky while they scroll, folding the group.
- [Description List](https://uicontext.com/docs/components/description-list.md) (`description-list`): A record's facts as label and value pairs, in rows or columns, with Copy for ids.
- [Fact Grid](https://uicontext.com/docs/components/fact-grid.md) (`fact-grid`): A few numbers about one thing, such as a customer's plan and seats, as small tiles.
