Skip to content
caliper ui docs

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.

Free
pnpm dlx shadcn@latest add @caliper/description-list

Northwind Trading

Customer since March 2024 · managed by Sofia Ortega

Details

Name
Northwind Trading
Billing email
billing@northwind.exampleInvoices and receipts go here
Customer ID
cus_9fQ2Lx81Zr
Plan
Growth Active
Balance
€1,240.00Due 31 Oct
Tax ID
Not set
Created
14 March 2024
Billing address
Rua do Ouro 120, 1100-063 Lisboa, Portugal
Installs components/ui/description-list.tsxDepends on @radix-ui/react-slot, lucide-reactMotion shared motion tokens

When 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

terminal
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.

example.tsx
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
PropTypeDefaultDescription
items *readonly DescriptionItem[]—
columns1 | 21Two pairs per row on wide containers.
loadingbooleanfalse
titlestring—A small heading over the list, e.g. "Billing details".
classNamestring—

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.

KeyBehaviour
EscapeCloses or cancels, then returns focus to where it came from.

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.

All Table examples