Skip to content
Haze UI

Credit card

A bank-card face at the 1.586 ID-1 ratio with masked number, holder, expiry, network name and a frozen or expired tag.

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

When to use

  • A wallet or billing page lists the cards on file and each needs a recognizable face.
  • The card status, frozen or expired, must be visible without opening a menu.
  • A saved card is confirmed after checkout with only the last four digits.

When not to use

  • The customer types a new card number; use payment-card-input.
  • A card must turn over to show a back face; use card-flip.
  • The content is generic, not a payment card; use card.

Installation

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

pnpm dlx shadcn@latest add @haze/credit-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
networkstringVisaNetwork name rendered as text. It is never drawn as a logo.
last4string4242Last four digits. The rest of the number is always masked.
holderstringIngrid SolheimName on the card.
expirystring08/28Expiry date as MM/YY.
labelstringBusiness cardName the owner gave the card.
status"active" | "frozen" | "expired"activeShown as a tag with an icon and text.
statusLabelstring–Replaces the default status word, for translation.
chipbooleantrueDraws the small chip mark.
endingLabelstringCard ending inScreen reader words read before the last four digits.
expiryLabelstringExpiresWord before the expiry date.
classstring–Classes for the card, such as a max width.

Accessibility

  • The masked dots are hidden from screen readers, which hear 'Card ending in 4242' instead.
  • Status is a word plus an icon, so frozen and expired never depend on color.
  • Both surfaces use the theme's foreground pairs, so text keeps its contrast in light and dark.
  • The face is not interactive. Put a button or link beside it for actions such as freezing.

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

  • Customize with real content

    Adapt the Haze credit-card ui for our product. Replace the demo values of these props with our real content: network, last4, holder, expiry, label, status, statusLabel, chip, endingLabel, expiryLabel, class. Keep the layout, the heading level rules and these accessibility details: The masked dots are hidden from screen readers, which hear 'Card ending in 4242' instead. Status is a word plus an icon, so frozen and expired never depend on color. Both surfaces use the theme's foreground pairs, so text keeps its contrast in light and dark. The face is not interactive. Put a button or link beside it for actions such as freezing. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using credit-card, check it fits: use it when a wallet or billing page lists the cards on file and each needs a recognizable face.; the card status, frozen or expired, must be visible without opening a menu.; a saved card is confirmed after checkout with only the last four digits.. Avoid it when the customer types a new card number; use payment-card-input.; a card must turn over to show a back face; use card-flip.; the content is generic, not a payment card; use card.. Alternatives: @haze/payment-card-input, @haze/card-flip, @haze/card.

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