Description list
Structured semantic <dl> key-value metadata grid for account details, invoices, and API resource properties.
pnpm dlx shadcn@latest add @haze/description-list---
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>When to use
- Displaying account identifiers, billing metadata, or deployment properties
- Inspector drawers and detail views alongside tables
When not to use
- Tabular multi-row collections belong in table
- Single KPI figures belong in stat
Installation
Add the Haze registry to components.json once, then install Description list with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/description-listnpx shadcn@latest add @haze/description-listyarn dlx shadcn@latest add @haze/description-listbunx --bun shadcn@latest add @haze/description-listFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Workspace details" | Header title. |
| description | string | – | Optional subtitle under the heading. |
| items | DetailItem[] | – | Key-value pairs with optional monospace, semantic tone, and copy button. |
| columns | 1 | 2 | 3 | 2 | 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.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
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": "http://localhost:4329/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: http://localhost:4329/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.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.