Skip to content
Haze UI

Choice card

Radio options drawn as selectable cards, each with a title, a description and an optional trailing hint such as a price.

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

When to use

  • Picking a plan, a role or a deployment target where each option needs a sentence of explanation
  • Two to four options that deserve more visual weight than a plain radio list

When not to use

  • Long lists of options; use select
  • Short labels that fit in a compact row; use toggle-group
  • Choices where several can be picked at once

Installation

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

pnpm dlx shadcn@latest add @haze/choice-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
name*string–Shared radio name; the form submits the chosen value under it.
legend*string–Visible group title, announced as the group name.
options*{ value: string; title: string; description?: string; hint?: string; disabled?: boolean }[]–The cards; hint is short trailing text such as a price, and disabled turns off that card only.
valuestring–Value of the card that is checked on load.
columns1 | 21Layout; two columns apply from the sm breakpoint, narrower screens stack.
requiredboolean–One card must be picked before the form submits; set on every radio.
disabledboolean–Disables every card through the fieldset.
classstring–Extra classes on the fieldset.
...restattributes–Any other fieldset attribute, for example form or aria-describedby.

Keyboard interactions

Arrow keys
Move between cards and select the one reached
Tab
Enters or leaves the group at the checked card

Accessibility

  • The whole card is one label around a real radio, so the title, description and hint are read as the radio's name and the entire card is the click target.
  • The checked card gets a stronger border and a tinted background, and its radio box fills with a dot that scales in, so the state does not rely on color alone. Under forced colors the native radio is shown.
  • Disabled cards are dimmed, show a not-allowed cursor and ignore hover.
  • The focus outline is drawn around the card with has-focus-visible, not around the small radio.

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

  • Customize with real content

    Adapt the Haze choice-card ui for our product. Replace the demo values of these props with our real content: name, legend, options, value, columns, required, disabled, class, ...rest. Keep the layout, the heading level rules and these accessibility details: The whole card is one label around a real radio, so the title, description and hint are read as the radio's name and the entire card is the click target. The checked card gets a stronger border and a tinted background, and its radio box fills with a dot that scales in, so the state does not rely on color alone. Under forced colors the native radio is shown. Disabled cards are dimmed, show a not-allowed cursor and ignore hover. The focus outline is drawn around the card with has-focus-visible, not around the small radio. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using choice-card, check it fits: use it when picking a plan, a role or a deployment target where each option needs a sentence of explanation; two to four options that deserve more visual weight than a plain radio list. Avoid it when long lists of options; use select; short labels that fit in a compact row; use toggle-group; choices where several can be picked at once. Alternatives: @haze/radio-group, @haze/toggle-group, @haze/select.

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