# Description list

> Structured semantic <dl> key-value metadata grid for account details, invoices, and API resource properties.

- Kind: ui · Category: Data display · Interactivity: script
- Install: `npx shadcn@latest add @haze/description-list`
- File: `src/components/haze/ui/description-list.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/description-list

## Use when
- Displaying account identifiers, billing metadata, or deployment properties
- Inspector drawers and detail views alongside tables

## Avoid when
- Tabular multi-row collections belong in table
- Single KPI figures belong in stat

## Alternatives
- [table](https://hazeui.com/ui/table.md)
- [stat](https://hazeui.com/ui/stat.md)
- [item](https://hazeui.com/ui/item.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| title | `string` | "Workspace details" | no | Header title. |
| description | `string` |  | no | Optional subtitle under the heading. |
| items | `DetailItem[]` |  | no | Key-value pairs with optional monospace, semantic tone, and copy button. |
| columns | `1 \| 2 \| 3` | 2 | no | Responsive grid columns above small viewports. |

## Accessibility
- Uses semantic HTML <dl>, <dt>, and <dd> landmarks so screen readers pair every value with its label.
- Copy buttons announce clipboard confirmation through a polite live status region.

## Agent prompts

### Install and use

Install the Haze UI component "Description list" with `npx shadcn@latest add @haze/description-list`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import DescriptionList from "@/components/haze/ui/description-list.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/ui/description-list.md

### Customize with real content

Adapt the Haze description-list ui for our product. Replace the demo values of these props with our real content: title, description, items, columns. Keep the layout, the heading level rules and these accessibility details: Uses semantic HTML <dl>, <dt>, and <dd> landmarks so screen readers pair every value with its label. Copy buttons announce clipboard confirmation through a polite live status region. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using description-list, check it fits: use it when displaying account identifiers, billing metadata, or deployment properties; inspector drawers and detail views alongside tables. Avoid it when tabular multi-row collections belong in table; single kpi figures belong in stat. Alternatives: @haze/table, @haze/stat, @haze/item.

## Example requests that should lead here
- Add a two-column description list displaying workspace ID, region, and plan tier

## Source

```astro
---
import { Check, Copy } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface DetailItem {
  label: string;
  value: string;
  mono?: boolean;
  copyable?: boolean;
  tone?: "default" | "success" | "warning" | "destructive";
}

interface Props {
  title?: string;
  description?: string;
  items?: DetailItem[];
  columns?: 1 | 2 | 3;
  headingLevel?: 2 | 3 | 4;
  class?: string;
}

const {
  title = "Workspace details",
  description = "Configuration and billing identifiers.",
  items = [
    { label: "Organization", value: "Tidewell Studio" },
    { label: "Workspace ID", value: "ws_9f82c10a", mono: true, copyable: true },
    { label: "Plan tier", value: "Scale · Active", tone: "success" },
    { label: "Region", value: "eu-central-1", mono: true },
  ],
  columns = 2,
  headingLevel = 3,
  class: className,
} = Astro.props;

const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const gridCols = {
  1: "grid-cols-1",
  2: "grid-cols-1 sm:grid-cols-2",
  3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
}[columns];

const tones = {
  default: "text-foreground",
  success: "text-success",
  warning: "text-warning",
  destructive: "text-destructive",
};
---

<section data-haze-description-list class={cn("min-w-0 overflow-hidden rounded-xl border border-border bg-card text-card-foreground", className)}>
  {
    (title || description) && (
      <header class="border-b border-border px-4.5 py-3.5">
        {title && <Heading class="text-[0.9375rem]/5 font-medium tracking-[-0.01em] text-foreground">{title}</Heading>}
        {description && <p class="mt-0.5 text-xs/5 text-muted-foreground">{description}</p>}
      </header>
    )
  }
  <dl class={cn("grid divide-y divide-border bg-muted/25 sm:divide-y-0 sm:gap-px sm:bg-border", gridCols)}>
    {
      items.map((item) => (
        <div class="flex min-w-0 flex-col justify-between gap-1 bg-card px-4.5 py-3.5">
          <dt class="text-xs/4 font-medium text-muted-foreground">{item.label}</dt>
          <dd class="flex min-w-0 items-center justify-between gap-2 text-[0.8125rem]/5">
            <span class={cn("min-w-0 truncate font-medium", item.mono && "font-mono tabular-nums", tones[item.tone ?? "default"])}>
              {item.value}
            </span>
            {item.copyable && (
              <button
                type="button"
                data-dl-copy={item.value}
                aria-label={`Copy ${item.label}`}
                class="inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground active:scale-90 focus-visible:outline-2 focus-visible:outline-ring"
              >
                <Copy data-dl-ico="idle" class="size-3.5" aria-hidden="true" />
                <Check data-dl-ico="ok" class="hidden size-3.5 animate-pop text-success" aria-hidden="true" />
              </button>
            )}
          </dd>
        </div>
      ))
    }
  </dl>
  <span role="status" data-dl-status class="sr-only"></span>
</section>

<script>
  function initDescriptionLists() {
    document.querySelectorAll<HTMLElement>("[data-haze-description-list]:not([data-enhanced])").forEach((root) => {
      root.setAttribute("data-enhanced", "");
      const status = root.querySelector<HTMLElement>("[data-dl-status]");
      root.querySelectorAll<HTMLButtonElement>("[data-dl-copy]").forEach((btn) => {
        let timer = 0;
        btn.addEventListener("click", async () => {
          try {
            await navigator.clipboard.writeText(btn.dataset.dlCopy ?? "");
          } catch {}
          const idle = btn.querySelector<HTMLElement>('[data-dl-ico="idle"]');
          const ok = btn.querySelector<HTMLElement>('[data-dl-ico="ok"]');
          idle?.classList.add("hidden");
          ok?.classList.remove("hidden");
          if (status) status.textContent = "Copied value";
          window.clearTimeout(timer);
          timer = window.setTimeout(() => {
            idle?.classList.remove("hidden");
            ok?.classList.add("hidden");
          }, 1500);
        });
      });
    });
  }

  initDescriptionLists();
  if (!document.documentElement.hasAttribute("data-haze-dl-listener")) {
    document.documentElement.setAttribute("data-haze-dl-listener", "");
    document.addEventListener("astro:page-load", initDescriptionLists);
  }
</script>
```
