Skip to content
Generative UICard carouselMenu

Card carousel

Horizontal results such as places, products or events. Cards snap one by one, arrows page the rail and disable at either end, and images hold their frame while they load.

Places that snap card by card, with arrows that disable at either end.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/card-carousel.json

Usage

tsx
import { CardCarousel } from "@/components/ui/chatcn/card-carousel"

<CardCarousel
  title="Places to work from this afternoon"
  items={places}
  onSelect={(item) => send(`Tell me more about ${item.title}`)}
/>

Examples

Loading and empty

Reserved cards while results load, and a search with no results.

Props

PropTypeNotes
itemsCarouselItem[]id, title, subtitle?, image?, price?, rating?, reviews?, meta?, badge?, href?
itemWidthnumberDefault 224
aspectnumberImage ratio. Default 4 / 3
onSelect(item, index) => voidCards become buttons; with href they are links
renderItem(item, index) => ReactNodeYour own card
expectedCount, loading, streaming, empty

Keyboard

KeyAction
TabMove through cards; the rail scrolls the focused card into view
EnterOpen or select the focused card

Accessibility

  • A labelled carousel region; each card is a slide named with its position and title.
  • Arrow buttons have labels and disable at the ends. Ratings carry a hidden word, not just a star.

Motion

  • Paging scrolls smoothly, instantly under reduced motion. Images fade in over 200 ms. Cards that stream in rise 4 px once; a finished list appears at once.