# Expandable card

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

- Kind: ui · Category: Layout and media · Interactivity: native
- Install: `npx shadcn@latest add @haze/expandable-card`
- File: `src/components/haze/ui/expandable-card.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/expandable-card

## Use 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 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
- [accordion](https://hazeui.com/ui/accordion.md)
- [card](https://hazeui.com/ui/card.md)
- [dialog](https://hazeui.com/ui/dialog.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| id | `string` |  | yes | Unique caller supplied prefix for the control and its associated content. |
| title | `string` | Workspace retention | no | Heading in the disclosure summary. |
| description | `string` | Keep the details close without crowding the page. | no | Short secondary description beside the disclosure chevron. |
| headingLevel | `2 \| 3 \| 4` | 3 | no | Heading level appropriate to the containing page. |
| open | `boolean` | false | no | Whether the native disclosure starts expanded. |
| class | `string` |  | no | Additional classes on this component's outer wrapper. |

## 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.
- Key Enter / Space: Expand or collapse the focused card summary.
- Key Tab: Reach expanded links and controls after the summary.

## Agent prompts

### 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": "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 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: https://hazeui.com/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.

## Example requests that should lead here
- Put workspace retention details inside an expandable native card
- Add a compact project summary that reveals a link and longer explanation

## Source

```astro
---
import { ChevronDown } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface Props {
  id: string;
  title?: string;
  description?: string;
  headingLevel?: 2 | 3 | 4;
  open?: boolean;
  class?: string;
}
const { id, title = "Workspace retention", description = "Keep the details close without crowding the page.", headingLevel = 3, open = false, class: className } = Astro.props;
const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const slide = "supports-[interpolate-size:allow-keywords]:[interpolate-size:allow-keywords] supports-[interpolate-size:allow-keywords]:details-content:h-0 supports-[interpolate-size:allow-keywords]:details-content:overflow-clip supports-[interpolate-size:allow-keywords]:details-content:transition-[height,content-visibility] supports-[interpolate-size:allow-keywords]:details-content:transition-discrete supports-[interpolate-size:allow-keywords]:details-content:duration-300 supports-[interpolate-size:allow-keywords]:details-content:ease-snappy supports-[interpolate-size:allow-keywords]:open:details-content:h-auto";
---
<details id={id} open={open} class={cn("w-full min-w-0 overflow-hidden rounded-xl border border-border bg-card text-card-foreground transition-[border-color,box-shadow] duration-200 ease-snappy hover:border-border-strong open:border-border-strong", slide, className)}>
  <summary class="flex min-h-16 cursor-pointer list-none items-start justify-between gap-4 p-4.5 transition-colors duration-150 ease-snappy hover:bg-accent focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring [&::-webkit-details-marker]:hidden">
    <span class="grid min-w-0 gap-1"><Heading class="text-[1.0625rem]/6 font-medium tracking-[-0.01em]">{title}</Heading><span class="text-[0.8125rem]/5 text-muted-foreground">{description}</span></span>
    <ChevronDown aria-hidden="true" class="mt-0.5 size-4 shrink-0 text-muted-foreground transition-[rotate] duration-200 ease-spring motion-reduce:transition-none [[open]>summary_&]:rotate-180" />
  </summary>
  <div class="border-t border-border bg-muted p-4.5 text-[0.8125rem]/5 text-muted-foreground not-supports-[interpolate-size:allow-keywords]:animate-rise">
    <slot><p>Archived projects stay available for 90 days. Workspace owners can export a copy before the retention period ends.</p></slot>
  </div>
</details>
```
