Order #4821
- Customer
- Ada Okafor
- 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
layouteditabledisabledimport { DetailList, DetailListDetails, DetailListItem, DetailListTerm } from "@/components/ui/detail-list"
export function Order({ order, save }) {
return (
<DetailList>
<DetailListItem>
<DetailListTerm>Customer</DetailListTerm>
<DetailListDetails>{order.customer}</DetailListDetails>
</DetailListItem>
<DetailListItem
copyable editable
defaultValue={order.email}
validate={(v) => (v.includes("@") ? undefined : "Enter an email address.")}
onValueChange={(email) => save({ email })}
>
<DetailListTerm>Email</DetailListTerm>
<DetailListDetails />
</DetailListItem>
<DetailListItem copyable editable multiline defaultValue={order.address}>
<DetailListTerm>Delivery to</DetailListTerm>
<DetailListDetails />
</DetailListItem>
<DetailListItem
editable multiline
defaultValue={order.note}
onValueChange={(note) => save({ note })}
>
<DetailListTerm>Note</DetailListTerm>
<DetailListDetails />
</DetailListItem>
<DetailListItem copyable defaultValue={order.id}>
<DetailListTerm>Order ID</DetailListTerm>
<DetailListDetails>{(id) => <span className="font-mono">{id}</span>}</DetailListDetails>
</DetailListItem>
</DetailList>
)
}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
- 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
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>
);
}Edit the email and press Enter.
- ada.okafor@fastmail.com
import { useState } from 'react';
import { DetailList, DetailListDetails, DetailListItem, DetailListTerm } from '@/components/ui/detail-list';
export function Example() {
const [email, setEmail] = useState('ada.okafor@fastmail.com');
return (
<DetailList layout="stacked">
<DetailListItem
copyable
editable
value={email}
validate={(v) => (v.includes('@') ? undefined : 'Enter an email address.')}
onValueChange={setEmail}
>
<DetailListTerm>Email</DetailListTerm>
<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
details.cancel() refuses it.value, setValue, save(value?), cancel, onKeyDown and fieldProps to spread on the field. Save, Cancel and validate still apply.Takes the props of the element it renders.
Agent
Inside an AgentProvider, it appears in agent.snapshot() as input.
Reads
labelThe row's term, such as Email.
componentinput, or textarea for a multiline row.
valueThe 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
dlofdtanddd, 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-labelledbyon 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.