Detail List

Labelled values for one record, with copy and inline edit.

Source
$npx @dinachi/cli@latest add detail-list

Order #4821

Customer
Ada Okafor
Email
ada.okafor@fastmail.com
Delivery to
Flat 4, 21 Elgin Crescent London W11 2JD United Kingdom
Note
Leave with the concierge if no one answers.
Order ID
ord_8f2kq4821
layout
editable
disabled

Usage

import { DetailList, DetailListDetails, DetailListItem, DetailListTerm } from "@/components/ui/detail-list"

export function Order() {
  return (
    <DetailList>
      <DetailListItem>
        <DetailListTerm>Customer</DetailListTerm>
        <DetailListDetails>Ada Okafor</DetailListDetails>
      </DetailListItem>
      <DetailListItem copyable editable defaultValue="ada.okafor@fastmail.com">
        <DetailListTerm>Email</DetailListTerm>
        <DetailListDetails />
      </DetailListItem>
    </DetailList>
  )
}

Examples

Order #4821

Status
Pending
Customer
Ada Okafor
Email
ada.okafor@fastmail.com
Placed
17 Nov 2026, 15:42
Amount
£204.00 · 2 items
Payment
Visa ending 4242
Delivery to
Flat 4, 21 Elgin Crescent London W11 2JD United Kingdom
Note
Leave with the concierge if no one answers.
Order ID
ord_8f2kq4821
An order with labels beside values. Point at a row for its copy and edit buttons.
import { Badge } from '@/components/ui/badge';
import { DetailList, DetailListDetails, DetailListItem, DetailListTerm } from '@/components/ui/detail-list';

export function Example() {
  return (
    <DetailList>
      <DetailListItem>
        <DetailListTerm>Status</DetailListTerm>
        <DetailListDetails><Badge variant="outline">Pending</Badge></DetailListDetails>
      </DetailListItem>
      <DetailListItem>
        <DetailListTerm>Customer</DetailListTerm>
        <DetailListDetails>Ada Okafor</DetailListDetails>
      </DetailListItem>
      <DetailListItem copyable editable defaultValue="ada.okafor@fastmail.com">
        <DetailListTerm>Email</DetailListTerm>
        <DetailListDetails />
      </DetailListItem>
      <DetailListItem copyable editable multiline defaultValue={'Flat 4, 21 Elgin Crescent\nLondon W11 2JD\nUnited Kingdom'}>
        <DetailListTerm>Delivery to</DetailListTerm>
        <DetailListDetails />
      </DetailListItem>
      <DetailListItem editable multiline defaultValue="Leave with the concierge if no one answers.">
        <DetailListTerm>Note</DetailListTerm>
        <DetailListDetails />
      </DetailListItem>
      <DetailListItem copyable defaultValue="ord_8f2kq4821">
        <DetailListTerm>Order ID</DetailListTerm>
        <DetailListDetails>{(id) => <span className="font-mono">{id}</span>}</DetailListDetails>
      </DetailListItem>
    </DetailList>
  );
}

Notes

Actions on demand

Copy and Edit show on the row you point at or tab into. Rows without them take no extra space, so a read-only list lines up with an editable one.

Editing in place

Edit turns the value into a field. Enter saves, Escape cancels, and focus goes back to the Edit button either way. A saved change flashes the row for under 300ms, and not at all with reduced motion.

Your own editor

renderEditor swaps the text field for any field, such as a Select of statuses. Spread fieldProps on it so it takes focus, is named by the term and is described by an error. Call setValue and let Save commit, or save(value) to commit on the choice itself. Values stay strings, so the agent still sets the row with setValue.

Phone

Below 768px labels sit above values, and Copy and Edit are always shown at 44px, since there is no hover.

API

layout"side" | "stacked" = "side"
Labels beside values, or above them. Below 768px they always sit above.

Agent

Inside an AgentProvider, it appears in agent.snapshot() as input.

Reads

label

The row's term, such as Email.

component

input, or textarea for a multiline row.

value

The row's value.

Actions

setValue("ada@okafor.dev")

Saves a new value and flashes the row, as a person's save does.

clear()

Saves an empty value, through validate like any other.

Each editable row registers itself. An agent's value runs through validate first, and its message comes back as the step's error. Then it reaches onValueChange, where isAgentChange(details) is true and details.cancel() refuses it. A row a person is editing refuses the agent, so it never overwrites a draft. Copy buttons are plain buttons the agent can press.

await agent.act({
  steps: [{ ref: "Email", action: "setValue", args: ["ada@okafor.dev"] }],
})

Accessibility

  • A native dl of dt and dd, so a screen reader announces each label with its value.
  • Each button is named by its action and the row, such as Copy Email, through aria-labelledby on the term.
  • Copying says Copied in a polite live region, and the icon turns to a tick. A blocked or missing clipboard says Could not copy.
  • The field is named by the term. A refused value sets aria-invalid, is linked as its description and is announced.
  • Focus returns to the Edit button after saving or cancelling.