Default
The shadcn demo: five cards and two arrows. Previous is dashed on the first slide; swipe or drag, click the arrows, or press Left and Right while focus is inside.
Embla's smooth, swipeable scroller with paper furniture: hand-drawn arrows outside the slides (dashed when there is nowhere to go) and, if you want it, a tally under them: one stroke per slide, groups of five with the fifth struck across the other four, the current slide in blue felt. Horizontal or vertical, any number of slides per view, autoplay only if you plug it in.
npx shadcn@latest add @wobko/carouselFirst time here? Add the registry to components.json first. How to install
The shadcn demo: five cards and two arrows. Previous is dashed on the first slide; swipe or drag, click the arrows, or press Left and Right while focus is inside.
CarouselDots keeps count like a tally: a stroke per slide, the fifth of each group struck across the four before it, the current one in blue felt (click any to go there). Seven slides, two per view on wide screens, and the API from setApi drives the caption.
orientation="vertical": the slides scroll up and down, the arrows sit above and below with up and down arrows, and the keys are ArrowUp and ArrowDown. Give the track a fixed height and offset the gap with -mt on the content and pt on the items.
A real use: a trip's snapshots as taped-down polaroids. The line under the tally reads the current photo's date from the Embla API (the polaroid already carries its own caption); the tally counts them, and loops keep both arrows alive.
A slide is as wide as its `basis-*` class: `basis-1/2` shows two, `basis-1/3` three. Breakpoint variants change it with the screen (here half from md, a third from lg), and `align: "start"` lines the first slide up with the left edge instead of centring it.
The gap is padding at the start of each item, pulled back by the same negative margin on the content, so the first slide still meets the edge. The default is `ps-4` with `-ms-4`; here it is `ps-1` with `-ms-1` for a tight row. Use the logical `ms`/`ps` (not `ml`/`pl`) so right-to-left pages work; vertical carousels use `pt` and `-mt`.
Anything Embla understands goes in `plugins`; this small autoplay is written inline, so no extra package. It holds still while the pointer, focus or a finger is on the carousel, keeps a Pause through a resize, never starts for readers who asked for less motion, and has a real Pause button (WCAG 2.2.2).
The `role="region"` (`aria-roledescription="carousel"`, give it a name) that owns the Embla instance and the keys, plus a screen-reader status ("Slide 2 of 5").
| Prop | Type | Default | Description |
|---|---|---|---|
| opts | EmblaOptionsType | - | Embla options: `loop`, `align`, `startIndex`, `dragFree`, `slidesToScroll`, `direction: "rtl"` ... (`axis` follows `orientation`). |
| plugins | EmblaPluginType[] | - | Embla plugins. Autoplay is not on by default: install `embla-carousel-autoplay` and pass it here if you really want it (and give people a way to stop it). |
| orientation | "horizontal" | "vertical" | "horizontal" | The axis the slides scroll along. |
| setApi | (api: CarouselApi) => void | - | Receive the Embla API to read the current slide, listen to `select`, or scroll from outside. |
| seed | string | number | - | Pins the hand of the tally's strokes. Default: from useId(). |
The files the CLI copies into your project.
Loading the source