Skip to content
Haze UI

Expandable card

A native details card with a compact summary, animated disclosure and a slot for additional content.

pnpm dlx shadcn@latest add @haze/expandable-card
Open preview in a new tab
Liveno JavaScript

When to use

  • A card needs to keep its main information readable while making secondary details available on demand.
  • Expanded content belongs in the current document flow and should work without client code.

When not to use

  • Use accordion for a coordinated set of repeated question and answer rows.
  • Use dialog when opening the details must move focus into a modal task.

Installation

Add the Haze registry to components.json once, then install Expandable card with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/expandable-card
First 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

PropTypeDefaultDescription
id*string–Unique caller supplied prefix for the control and its associated content.
titlestringWorkspace retentionHeading in the disclosure summary.
descriptionstringKeep the details close without crowding the page.Short secondary description beside the disclosure chevron.
headingLevel2 | 3 | 43Heading level appropriate to the containing page.
openbooleanfalseWhether the native disclosure starts expanded.
classstring–Additional classes on this component's outer wrapper.

Keyboard interactions

EnterSpace
Expand or collapse the focused card summary.
Tab
Reach expanded links and controls after the summary.

Accessibility

  • The summary is the native disclosure control, so the browser exposes expanded state and manages the closed content.
  • The summary target spans the full card header and its focus outline stays inside the card's clipped edge.
  • Supported browsers interpolate the details panel height; other browsers animate only the appearing content and the theme disables both paths for reduced motion.
  • The caller selects the summary heading level and can put normal links or form controls inside the default content slot.

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 "Expandable card" with `npx shadcn@latest add @haze/expandable-card`. 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 ExpandableCard from "@/components/haze/ui/expandable-card.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/expandable-card.md

  • Customize with real content

    Adapt the Haze expandable-card ui for our product. Replace the demo values of these props with our real content: id, title, description, headingLevel, open, class. Keep the layout, the heading level rules and these accessibility details: The summary is the native disclosure control, so the browser exposes expanded state and manages the closed content. The summary target spans the full card header and its focus outline stays inside the card's clipped edge. Supported browsers interpolate the details panel height; other browsers animate only the appearing content and the theme disables both paths for reduced motion. The caller selects the summary heading level and can put normal links or form controls inside the default content slot. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using expandable-card, check it fits: use it when a card needs to keep its main information readable while making secondary details available on demand.; expanded content belongs in the current document flow and should work without client code.. Avoid it when use accordion for a coordinated set of repeated question and answer rows.; use dialog when opening the details must move focus into a modal task.. Alternatives: @haze/accordion, @haze/card, @haze/dialog.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog