# Record Detail

> One record's title, fields and actions, edited in place.

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

Group: Records.

## When to use

One record's title, fields and actions, edited in place. Use [Description List](https://uicontext.com/docs/components/description-list.md) instead when the facts are read-only.

## 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 { Detail } from "./ui/uicontext/components/Detail.ts"

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

export const TaskPage = (h: Html.H<typeof Message.Type>, task: Item, fields: ReadonlyArray<Property>, outcomes: ReadonlyArray<Outcome>) =>
	Detail(h, {
		props: { record: task, fields, titleEditable: true, actions: [{ id: "archive", label: "Archive" }], outcomes },
		onEmit: {
			RequestedOpen: () => undefined,
			RequestedEdit: (edit) => Message.RequestedEditTask(edit),
			RequestedAction: ({ items }) => Message.RequestedArchive({ id: items[0] ?? task.id }),
		},
		slots: { body: h.p.children(task.note ?? "") },
	})
```

## Examples

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

### An issue

The example the page opens with: Record Detail in “An issue”.

```ts title="src/demo.ts" source="www/src/examples/record-detail/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 { Detail } from "./ui/uicontext/components/Detail.ts"
import { Item, Value } from "./ui/uicontext/components/Property.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { Toaster } from "./ui/uicontext/components/Toast.ts"
import { color } from "./ui/uicontext/components/tokens.stylex.ts"
import { applyEdit, issueFields, issues } from "./issues.ts"

// Each edit shows a toast with Undo, which puts back the value the app had before it. Mod+Z in the
// record does the same, and Mod+Shift+Z redoes.

const styles = stylex.create({
	frame: { inlineSize: "100%" },
	body: { margin: 0, color: color.muted, lineHeight: 1.6 },
})

const Edited = Schema.Struct({ request: Schema.String, key: Schema.String, before: Value })

const Message = UiSchema.TaggedEnum({
	RequestedEditIssue: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },
	ClickedUndo: { request: Schema.String },
})

export const IssueDetail = Html.component({
	name: "IssueDetail",
	model: Schema.Struct({ record: Item, outcomes: Schema.Array(Outcome), edits: Schema.Array(Edited) }),
	message: Message,
}).make({
	init: () => ({ record: issues[0]!, outcomes: [], edits: [] }),
	update: {
		// the app keeps what each edit replaced, so a toast's Undo can put it back
		RequestedEditIssue: ($, { request, key, value }) =>
			$.evolve({
				edits: (edits) => [...edits.slice(-20), { request, key, before: $.model.record.values[key] ?? (key === "title" ? $.model.record.title : null) }],
				record: (record) => applyEdit(record, key, value),
				outcomes: (o) => [...o.slice(-10), { _tag: "Accepted", request }],
			}),
		ClickedUndo: ($, { request }) => {
			const edit = $.model.edits.find((e) => e.request === request)
			return edit === undefined
				? $.model
				: $.evolve({
						record: (record) => applyEdit(record, edit.key, edit.before),
						edits: (edits) => edits.filter((e) => e.request !== request),
					})
		},
	},
	view: (h, { record, outcomes }) =>
		Toaster(h, {
			action: (toast) =>
				toast.id.startsWith("edited:") ? { label: "Undo", message: Message.ClickedUndo({ request: toast.id.slice("edited:".length) }) } : undefined,
			children: [
				h.div.attrs(sx(styles.frame)).children(
					Detail(h, {
						props: {
							record,
							fields: issueFields,
							titleEditable: true,
							trail: ["Engineering", record.prefix ?? record.id],
							actions: [{ id: "archive", label: "Archive" }],
							outcomes,
							undoToast: true,
						},
						onEmit: {
							RequestedOpen: () => undefined,
							RequestedEdit: (edit) => Message.RequestedEditIssue(edit),
							RequestedAction: () => undefined,
						},
						slots: {
							body: h.p.attrs(sx(styles.body)).children(
								"Sign-in links last 10 minutes, but the mail queue can take up to 14 at peak. Raise the lifetime to 30 minutes and add a test for a slow queue.",
							),
						},
					}),
				),
			],
		}),
})
```

### Archived

A banner with an action, every field locked with the reason, and a shorter properties panel.

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

// An archived issue: a banner says so and offers Restore, `readOnly` locks every field with the
// reason, and `panel` shows only the fields that matter here.

const styles = stylex.create({
	frame: { inlineSize: "100%" },
	body: { margin: 0, color: color.muted, lineHeight: 1.6 },
})

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

export const ArchivedIssue = Html.component({
	name: "ArchivedIssue",
	model: Schema.Struct({ record: Item, archived: Schema.Boolean }),
	message: Message,
}).make({
	init: () => ({ record: issues.find((issue) => issue.id === "eng-118")!, archived: true }),
	update: { RequestedRestore: ($) => $.evolve({ archived: false }) },
	view: (h, { record, archived }) =>
		h.div.attrs(sx(styles.frame)).children(
			Detail(h, {
				props: {
					record,
					fields: issueFields,
					panel: ["status", "assignee", "labels", "due"],
					trail: ["Design", record.prefix ?? record.id],
					banner: archived
						? { tone: "warning", text: "This issue was archived on 24 November.", action: { id: "restore", label: "Restore" } }
						: null,
					...(archived ? { readOnly: "Restore the issue to edit it." } : {}),
				},
				onEmit: {
					RequestedOpen: () => undefined,
					RequestedAction: () => Message.RequestedRestore(),
					RequestedEdit: () => undefined,
				},
				slots: {
					body: h.p.attrs(sx(styles.body)).children("Badge text on the dark theme was 3.9:1. Raised it to 4.6:1 for every status color."),
				},
			}),
		),
})
```

### Stepping through a list

The arrows in the header, or `j` and `k`, open the previous and next record. Activity sits under the body.

This example also uses Activity Feed and Domain. Install them too:

```sh
npx shadcn@latest add checkfu/uicontext/activity-feed checkfu/uicontext/domain
```

```ts title="src/stepping.ts" source="www/src/examples/record-detail/stepping.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 { Activity } from "./ui/uicontext/components/Activity.ts"
import { Detail } from "./ui/uicontext/components/Detail.ts"
import { Item, Value } from "./ui/uicontext/components/Property.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color } from "./ui/uicontext/components/tokens.stylex.ts"
import { applyEdit, issueFields, issues } from "./issues.ts"
import { ada, now, scout } from "./team.ts"

// A triage pass: the arrows in the header, or j and k, open the previous and next issue of the
// list this one came from. The activity slot holds the record's history; the app decides what
// goes there.

const styles = stylex.create({
	frame: { inlineSize: "100%" },
	body: { margin: 0, color: color.muted, lineHeight: 1.6 },
})

const Message = UiSchema.TaggedEnum({
	RequestedEditIssue: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },
	RequestedOpenIssue: { item: Schema.String },
})

export const TriageDetail = Html.component({
	name: "TriageDetail",
	model: Schema.Struct({ records: Schema.Array(Item), open: Schema.String, outcomes: Schema.Array(Outcome) }),
	message: Message,
}).make({
	init: () => ({ records: issues, open: issues[2]!.id, outcomes: [] }),
	update: {
		RequestedEditIssue: ($, { request, item, key, value }) =>
			$.evolve({
				records: (records) => records.map((r) => (r.id === item ? applyEdit(r, key, value) : r)),
				outcomes: (o) => [...o.slice(-10), { _tag: "Accepted", request }],
			}),
		RequestedOpenIssue: ($, { item }) => $.evolve({ open: item }),
	},
	view: (h, { records, open, outcomes }) => {
		const index = Math.max(0, records.findIndex((r) => r.id === open))
		const record = records[index]!
		return h.div.attrs(sx(styles.frame)).children(
			Detail(h, {
				props: {
					agentId: "detail:triage",
					record,
					fields: issueFields,
					titleEditable: true,
					trail: ["Engineering", "Triage", record.prefix ?? record.id],
					position: {
						index,
						count: records.length,
						previous: records[index - 1]?.id ?? null,
						next: records[index + 1]?.id ?? null,
					},
					outcomes,
				},
				onEmit: {
					RequestedEdit: (edit) => Message.RequestedEditIssue(edit),
					RequestedOpen: ({ item }) => Message.RequestedOpenIssue({ item }),
					RequestedAction: () => undefined,
				},
				slots: {
					body: h.p.attrs(sx(styles.body)).children(record.note ?? "No description yet."),
					activity: Activity(h, {
						key: record.id,
						props: {
							label: "Activity",
							agentId: "activity:triage",
							now,
							entries: [
								{ id: `${record.id}-1`, actor: ada, action: "created the issue", at: "2026-11-28T09:12:00Z" },
								{
									id: `${record.id}-2`,
									actor: scout,
									onBehalfOf: ada,
									action: "set the priority",
									to: { label: "High" },
									at: "2026-11-30T16:40:00Z",
								},
							],
						},
						onEmit: { RequestedRestore: () => 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 } }
```

```ts title="src/team.ts" source="www/src/examples/_shared/team.ts"
import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"

// The people in the examples: three teammates and their agent.

export const ada: Actor = { id: "ada", name: "Ada Lovelace", kind: "person" }
export const ben: Actor = { id: "ben", name: "Ben Okafor", kind: "person" }
export const mira: Actor = { id: "mira", name: "Mira Patel", kind: "person" }
export const scout: Actor = { id: "scout", name: "Scout", kind: "agent" }
export const members: ReadonlyArray<Actor> = [scout, ben, mira, ada]

/** "Today" in these examples, so the day separators read the same for every visitor. */
export const now = "2026-12-01T12:00:00Z"
```

## API reference

**Props**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `agentId` | `string` | `detail:<record id>` | This pane's id for agents, unique on the page; `detail:<record id>` by default |
| `record` (required) | `Item` | — | The record this page shows |
| `fields` (required) | `Property[]` | — | Every field the record can have, with its kind and choices |
| `panel` | `string[]` | — | Which fields the panel shows, in order; every field by default |
| `shortcuts` | `FieldShortcut[]` | — | Single keys that open a field's picker from anywhere on the page outside a text field: `{ key: "s", field: "status" }`. Leave it out where a list on the page takes the same keys. |
| `titleEditable` | `boolean` | — | The title can be edited here |
| `undoToast` | `boolean` | — | After each edit, a toast saying what changed, with id `edited:<request>`: give it Undo through the Toaster's `action` and put back the value the app had. Mod+Z here undoes too, toast or not. |
| `trail` | `string[]` | — | What the trail above the title says: ["Engineering", "ENG-12"] |
| `banner` | `DetailBanner \| null` | — | A line above the body, such as a duplicate notice, with an optional button |
| `actions` | `ItemAction[]` | — | Buttons in the header: "Archive", "Delete" (consequential) |
| `readOnly` | `string` | — | Why nothing here can be edited: "This issue is in the trash" |
| `loading` | `boolean` | — | Shows placeholders while the record loads |
| `outcomes` | `Outcome[]` | — | How the app settled each requested edit: pending, accepted, or refused with a reason |
| `showLocks` | `boolean` | `off` | A lock beside read-only properties; off by default (their reason shows on focus either way) |
| `panelLabel` | `string` | `"Properties"` | The side panel's heading; "Properties" by default |
| `locale` | `string` | — | The locale numbers and dates are formatted in; the browser's by default |
| `position` | `{ index, count, previous, … }` | — | Where the record sits in the list it was opened from, with its neighbours' ids: the header shows "3 of 40" and steps to them, by its buttons or j and k |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `RequestedEdit` | `{}` | One field's (or the title's) new value; answer through `outcomes` with the same `request` |
| `RequestedAction` | `{}` | A header or banner action, on this record: `items` is `[record.id]` |
| `RequestedOpen` | `{}` | The previous or next record, from `position`: open it |

**Slots**: `body`, `activity`, `footer`

**Agent actions**

| Action | Description |
| --- | --- |
| `ClickedStep` | Open the previous (by -1) or next (by 1) record of the list this one was opened from |
| `CommittedEdit` | Set one field (or title). value: an option value, a list of them (multi-select, relation), text, a number (number, rating), an ISO date, true/false, a list of file URLs, or null to clear. Rollups and formulas are computed and can't be set |
| `ClickedAction` | Run one of the header's actions; destructive ones name this item as the target |
| `ClickedBannerAction` | Press the banner's button (see the banner) |

## Keyboard and accessibility

- Each field is a button that opens its editor; Escape closes it without saving.
- A read-only field says why when it has focus or is tapped, read as its description, and a refused edit restores the old value.

## Installation

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

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

It writes these files:

- `src/ui/uicontext/components/Button.ts`
- `src/ui/uicontext/components/CellHint.ts`
- `src/ui/uicontext/components/Detail.ts`
- `src/ui/uicontext/components/Glyph.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/Kbd.ts`
- `src/ui/uicontext/components/Motion.ts`
- `src/ui/uicontext/components/PageKeys.ts`
- `src/ui/uicontext/components/Property.ts`
- `src/ui/uicontext/components/RecordKeys.ts`
- `src/ui/uicontext/components/RequestNonce.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/domain/Format.ts`
- `src/ui/uicontext/components/domain/Glyph.ts`
- `src/ui/uicontext/components/domain/Outcome.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/variants.ts`

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

## Source

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

## Used in

- [Task manager](https://uicontext.com/blocks/issue-tracker.md)
- [Database](https://uicontext.com/blocks/tables.md)
- [CRM](https://uicontext.com/blocks/crm.md)
- [Issue workspace](https://uicontext.com/blocks/issue-workspace.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.
