Skip to content
Haze UI

Card

Bordered surface with an optional header, a body slot and a footer band; it can lift on hover when the whole card is a link.

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

When to use

  • Grouping a settings section, a form or a summary on a darker page background
  • A header with a title and one action, such as a badge or a small button, next to it
  • A footer row of buttons that belongs to the card's content

When not to use

  • Wrapping a whole page section; use a plain section with a heading
  • Cards nested inside cards; use a separator inside one card

Installation

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

pnpm dlx shadcn@latest add @haze/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
titlestring–Card heading. The header is drawn when a title, a description or the action slot exists.
descriptionstring–One muted line under the title.
headingLevel2 | 3 | 43Tag used for the title, so the card fits the heading outline of the page.
padding"sm" | "md""md"Inner spacing: 16 px for sm, 24 px for md.
interactivebooleanfalseLifts the card 2 px on hover and strengthens its border. Use it only when the whole card leads somewhere, for example with a stretched link inside.
classstring–Extra classes on the outer box.
default slotslot–Card body.
action slotslot–Top-right of the header, for a badge or a button.
footer slotslot–Footer band with a top border and a darker fill, for buttons or a note.

Accessibility

  • The title is a real heading whose level you choose with headingLevel, so a card list does not skip levels.
  • The card itself has no role and is not focusable; put links and buttons inside it and let each one carry its own focus ring.
  • Do not wrap the card in an anchor. For a card that is one link, set interactive, add class="relative" and give one link inside it an after:absolute after:inset-0 overlay, so there is one focusable element with a clear name. The card shows its stronger border while that link has focus.
  • The hover lift is a translate and a shadow, switched off under prefers-reduced-motion. For a list row that is one link, the item component with href is the alternative.

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

  • Customize with real content

    Adapt the Haze card ui for our product. Replace the demo values of these props with our real content: title, description, headingLevel, padding, interactive, class, default slot, action slot, footer slot. Keep the layout, the heading level rules and these accessibility details: The title is a real heading whose level you choose with headingLevel, so a card list does not skip levels. The card itself has no role and is not focusable; put links and buttons inside it and let each one carry its own focus ring. Do not wrap the card in an anchor. For a card that is one link, set interactive, add class="relative" and give one link inside it an after:absolute after:inset-0 overlay, so there is one focusable element with a clear name. The card shows its stronger border while that link has focus. The hover lift is a translate and a shadow, switched off under prefers-reduced-motion. For a list row that is one link, the item component with href is the alternative. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using card, check it fits: use it when grouping a settings section, a form or a summary on a darker page background; a header with a title and one action, such as a badge or a small button, next to it; a footer row of buttons that belongs to the card's content. Avoid it when wrapping a whole page section; use a plain section with a heading; cards nested inside cards; use a separator inside one card. Alternatives: @haze/item, @haze/stat, @haze/separator.

Dependencies

  • @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