Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Carousel

ProNew

Native scroll snapping with mouse drag, arrow keys, and slides and dots that track the scroll continuously.

Installation

pnpm dlx shadcn@latest add @viewport/carousel

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
label*string

Accessible name, e.g. "Featured work".

—
slideWidthstring

Width of one slide as any CSS length. Percentages are of the carousel.

"min(78%, 26rem)"
gapnumber

Space between slides in pixels.

16
onIndexChange(index: number) => void

Called when a different slide settles in the middle.

—
children*React.ReactNode

One slide per child.

—
classNamestring—

Accessibility

  • Labelled carousel; each slide reports its position.
  • Arrow keys, Home and End move between slides; the position is announced.
  • Swipe and trackpad scrolling are native; nothing scales under reduced motion.