Skip to content
Haze UI

Carousel Cards

An editorial peeking card carousel with plain media panels, favorite toggles, tabular counter, and scroll-snap controls.

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

When to use

  • Readers browse a curated horizontal strip of travel, product, or editorial cards where the next card peeks in.
  • Each card benefits from visual artwork, a quick-save toggle, and compact rating or pricing metadata.

When not to use

  • Only one full-width slide should fill the viewport at a time. Use carousel instead.
  • Users make binary keep-or-skip decisions on one card at a time. Use card-stack.

Installation

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

pnpm dlx shadcn@latest add @haze/carousel-cards
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 ID for the horizontal scroll track.
eyebrowstring"Picked for this autumn"Small editorial eyebrow line above the carousel heading.
labelstring"Weekend escapes"Visible heading naming the card carousel region.
itemsEscapeCard[]–Card items with title, location, badge, rating, review count and price (scene is accepted but ignored).
previousLabelstring"Previous card"Accessible label for the previous card button.
nextLabelstring"Next card"Accessible label for the next card button.
headingLevel2 | 3 | 43Heading level for the carousel heading.
default slotslot–Optional custom list items replacing the default items prop.
classstring–Additional classes on the outer carousel section.

Keyboard interactions

LeftRight
Step to the previous or next card when the track is focused.
HomeEnd
Jump to the first or last card in the carousel.
Tab then Enter or Space
Activate previous/next controls or toggle save buttons on individual cards.

Accessibility

  • The track uses native CSS scroll-snap with tabindex=0 so keyboard and touch scrolling work inside the track without page overflow.
  • Favorite toggle buttons expose descriptive aria-label names, aria-pressed state, and polite live announcements.
  • Scroll stepping respects prefers-reduced-motion by switching to instant scrolling.

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 "Carousel Cards" with `npx shadcn@latest add @haze/carousel-cards`. 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 CarouselCards from "@/components/haze/ui/carousel-cards.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/carousel-cards.md

  • Customize with real content

    Adapt the Haze carousel-cards ui for our product. Replace the demo values of these props with our real content: id, eyebrow, label, items, previousLabel, nextLabel, headingLevel, default slot, class. Keep the layout, the heading level rules and these accessibility details: The track uses native CSS scroll-snap with tabindex=0 so keyboard and touch scrolling work inside the track without page overflow. Favorite toggle buttons expose descriptive aria-label names, aria-pressed state, and polite live announcements. Scroll stepping respects prefers-reduced-motion by switching to instant scrolling. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using carousel-cards, check it fits: use it when readers browse a curated horizontal strip of travel, product, or editorial cards where the next card peeks in.; each card benefits from visual artwork, a quick-save toggle, and compact rating or pricing metadata.. Avoid it when only one full-width slide should fill the viewport at a time. use carousel instead.; users make binary keep-or-skip decisions on one card at a time. use card-stack.. Alternatives: @haze/carousel, @haze/card-stack, @haze/bento-tile.

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