Skip to content
Haze UI

Card flip

A tall two-sided event pass card that flips in 3D via an explicit button to reveal a check-in code and venue access notes.

pnpm dlx shadcn@latest add @haze/card-flip
Open preview in a new tab
Livesmall script

When to use

  • A compact vertical pass, credential, or summary card has a focused reverse side such as a check-in code or access details
  • Users benefit from toggling between a display face and structured back metadata within the same footprint

When not to use

  • Both views need to be read or compared at the same time. Use card or expandable-card.
  • The back face contains long multi-section content or forms. Use expandable-card.

Installation

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

pnpm dlx shadcn@latest add @haze/card-flip
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 identifier for face landmarks and aria-controls links.
eyebrowstring"Admit one"Micro uppercase label in the top-left corner of the front face.
badgestring"VIP"Compact pass tier badge rendered in the top-right corner.
badgeTone"warning" | "brand" | "success" | "neutral""neutral"Semantic token tone for the pass badge and edition label.
editionstring"Vol. 04"Accent edition or series label above the display title.
titlestring"Fieldwork Sessions"Primary display heading shown on the front face.
metadata{ label: string; value: string; span?: 1 | 2 }[]–Two-column metadata fields rendered when no default slot is provided.
holderstring"Jordan Vale"Pass holder name displayed in the front footer.
serialstring"No. 004182"Monospace serial number shown on both faces.
backEyebrowstring"Check-in pass"Micro uppercase label above the back face heading.
backTitlestring"Entry & access"Heading shown on the back face.
accessNotes{ label: string; value: string }[]–Venue or access notes rendered beneath the check-in barcode when no back slot is provided.
frontActionLabelstring"Flip for check-in"Label for the button that flips to the back face.
backActionLabelstring"Show front"Label for the button that flips back to the front face.
defaultFlippedbooleanfalseStart with the back face visible.
headingLevel2 | 3 | 43Heading level for both face titles.
classstring–Additional classes on the outer perspective wrapper.

Keyboard interactions

Enter or Space
Flip the card when focused on the face toggle button.
Escape
Return from the back face to the front face.

Accessibility

  • Flipping is triggered by explicit accessible buttons with aria-pressed and aria-controls rather than hover, so touch and keyboard users can operate both faces.
  • The hidden face is marked inert when enhanced so keyboard focus and screen readers never enter the unseen side, and prefers-reduced-motion swaps faces without a 3D spin.
  • Decorative barcode and QR SVG graphics carry aria-hidden, and without JavaScript a visually hidden checkbox and paired labels preserve full toggle access.

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

  • Customize with real content

    Adapt the Haze card-flip ui for our product. Replace the demo values of these props with our real content: id, eyebrow, badge, badgeTone, edition, title, metadata, holder, serial, backEyebrow, backTitle, accessNotes, frontActionLabel, backActionLabel, defaultFlipped, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: Flipping is triggered by explicit accessible buttons with aria-pressed and aria-controls rather than hover, so touch and keyboard users can operate both faces. The hidden face is marked inert when enhanced so keyboard focus and screen readers never enter the unseen side, and prefers-reduced-motion swaps faces without a 3D spin. Decorative barcode and QR SVG graphics carry aria-hidden, and without JavaScript a visually hidden checkbox and paired labels preserve full toggle access. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using card-flip, check it fits: use it when a compact vertical pass, credential, or summary card has a focused reverse side such as a check-in code or access details; users benefit from toggling between a display face and structured back metadata within the same footprint. Avoid it when both views need to be read or compared at the same time. use card or expandable-card.; the back face contains long multi-section content or forms. use expandable-card.. Alternatives: @haze/card, @haze/expandable-card, @haze/boarding-pass.

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