Components
Description list
A record's details as label and value pairs, side by side when there is room, with copy and edit where the value sits.
pnpm dlx shadcn@latest add @caliper/description-listWhen to use
Use it for
- Detail panels for a customer, an order or a resource.
- Settings summaries people read more than change.
Skip it when
- Many records to compare; use a table.
- Long forms; use fields.
Installation
pnpm dlx shadcn@latest add @caliper/description-list
Adds its 5 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
This is the code behind the preview above.
import { useState, type ReactNode } from "react" import { Badge } from "@/components/ui/badge" import { Avatar } from "@/components/ui/avatar" import { cn } from "@/components/ui/lib/cn" import { DescriptionList } from "@/components/ui/description-list" function Panel({ title, context, action, className, children }: { title: string; context: string; action?: ReactNode; className?: string; children: ReactNode }) { return ( <section className={cn("grid w-full max-w-md gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}> <div className="flex flex-wrap items-start justify-between gap-3"> <div className="grid min-w-0 gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {action} </div> {children} </section> ); } const wait = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)); export function DescriptionListDemo() { const [name, setName] = useState("Northwind Trading"); const [email, setEmail] = useState("billing@northwind.example"); return ( <Panel title={name} context="Customer since March 2024 · managed by Sofia Ortega" action={<Avatar name={name} shape="square" className="size-10 text-sm" />} className="max-w-3xl" > <DescriptionList title="Details" columns={2} items={[ { term: "Name", value: name, edit: { value: name, onSave: setName } }, { term: "Billing email", value: email, hint: "Invoices and receipts go here", edit: { value: email, type: "email", onSave: async (next) => { await wait(500); if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(next)) throw new Error("Enter an email address like name@company.com."); if (next.startsWith("taken@")) throw new Error("Another customer already uses that address."); setEmail(next); }, }, }, { term: "Customer ID", value: "cus_9fQ2Lx81Zr", mono: true, copy: "cus_9fQ2Lx81Zr" }, { term: "Plan", value: <span className="inline-flex items-center gap-2">Growth <Badge variant="success">Active</Badge></span> }, { term: "Balance", value: "€1,240.00", mono: true, hint: "Due 31 Oct" }, { term: "Tax ID" }, { term: "Created", value: "14 March 2024" }, { term: "Billing address", value: "Rua do Ouro 120, 1100-063 Lisboa, Portugal" }, ]} /> </Panel> ); }
API reference
DescriptionList
component
Accessibility
It exposes alert semantics, with aria-labelledby, aria-busy, aria-hidden, aria-label, aria-invalid and aria-describedby kept in step with state. Changes that matter are announced through a live region.
Motion
Transitions use the shared duration and easing tokens. Under prefers-reduced-motion those tokens collapse to instant and travel distances go to zero, so state changes still happen without movement.
Related
- Data tableAccessible table markup with consistent cell styling and a scrollable region.
- ProseSpacing, a readable measure and quiet links for long-form markup you do not control, such as a Markdown render, release notes or a legal page.
- QR codeA QR code drawn as one crisp SVG path, encoded in the file with no dependency and no request. It stays dark on a white plate in both themes, keeps the quiet zone scanners need, and says what it is for to assistive technology.