Carousel
ProNewNative 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
| Prop | Type | Default |
|---|---|---|
| label* | stringAccessible name, e.g. "Featured work". | — |
| slideWidth | stringWidth of one slide as any CSS length. Percentages are of the carousel. | "min(78%, 26rem)" |
| gap | numberSpace between slides in pixels. | 16 |
| onIndexChange | (index: number) => voidCalled when a different slide settles in the middle. | — |
| children* | React.ReactNodeOne slide per child. | — |
| className | string | — |
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.