shadcn.io is not affiliated with official shadcn/ui
Components
Free
Carousel for Svelte
Step through slides with previous and next controls, for a gallery or a short onboarding sequence. For Svelte with Ark UI, when the slides won't all fit on the page.
Framework
UI library
Previous and next buttons move through a row of slides, one filling the frame.
Use it for a gallery, a few quotes, or a short onboarding sequence. For named panels people jump between, use Tabs. In Svelte, Ark UI keeps previous and next labeled, so an icon with no name is not enough.
Installation
Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Each card is narrower than the frame, so two sit side by side and a third can appear once the carousel is wide. Use that for thumbnails or logos, where one full-bleed slide wastes the row. The next card peeks in, which is the hint that more exist. Cap the width or the cards grow until that peek disappears.
Spacing
A multi-card row with a small gap, so neighboring borders do not touch. Tight spacing reads as one group, and a wide gutter reads as separate sections, which fights a carousel. A few pixels is enough when the cards already have an edge. Drop the gap for full-bleed photos that should meet.
Orientation
The track runs downward, about two cards in a fixed height, and the buttons point up and down. Set orientation to vertical and give the content a height, or the column grows with every slide and nothing actually scrolls. A short rail beside a detail view is the fit. A gallery across a page should stay horizontal, which is the default and the direction people expect to swipe.
Api
A line under the carousel says which slide is current, out of five, and updates as you move. The label is your markup, not a built-in caption, so it can match the way the rest of the page speaks. Use it when dots are not enough and a heading or side panel must stay in step. The FAQ shows how each stack reports that index.
Plugin
Slides advance on a two second timer and pause while the pointer is over the track. Leaving the track starts them again. Use a timer for a decorative gallery, not for a sentence someone must read. Keep previous and next, because autoplay is easy to miss, and pausing on hover is the minimum rather than a flourish.
Multiple
On a wide screen several cards share the row, and previous and next hide on small screens where one card already fills the width. Use several per view for tiles people compare, not for a hero. Hiding the buttons works only when a peek of the next card is hint enough. On touch, visible controls beat hoping for a swipe.
Rtl
The numerals are Arabic, and dir is rtl on the carousel, so forward sits where forward is on that page. Previous and next trade sides with the reading order. Set direction on the carousel itself. An ancestor with the right direction can still leave the scroll axis left to right, so try a translated slide rather than English cards with a direction attribute.
FAQ
How do I show several slides at once in the Carousel?
Set slidesPerPage, such as 3, along with the required slideCount, as in the Multiple demo. spacing sets the gap between slides.
How do I make the Carousel autoplay in Svelte?
Pass autoplay, or autoplay with a delay in milliseconds, and add loop so it starts over at the end. The Plugin demo also pauses it on hover.
Let readers pause it, and avoid autoplay for content they need time to read.
How do I get the current slide of the Carousel?
Control page and read it in onPageChange, which receives { page }, as in the Api demo.
How do I loop the Carousel back to the first slide?
Add loop: Next on the last slide goes back to the first.
How do I make a vertical Carousel?
Set orientation="vertical" and give CarouselContent a height, such as h-[270px], as in the Orientation demo. The previous and next buttons turn to point up and down.
Is the Ark UI Carousel accessible?
The previous and next buttons have labels, Previous slide and Next slide, so screen readers announce them.
Give the carousel a label that names its content, and don't hide essential information in slides people may never reach.
How do I install the Carousel in Svelte?
Run the command in the Installation section above: it adds carousel to your components/ui folder with the packages it needs. React and Solid use the shadcn CLI, Vue uses shadcn-vue and Svelte uses shadcn-svelte, each after its one-time setup.
API Reference
Carousel
<div>data-slot="carousel"
PropType
page?number
The controlled page of the carousel.
defaultPage?number
The initial page to scroll to when rendered.
Use when you don't need to control the page of the carousel.
Default
0
onPageChange?(details: PageChangeDetails) → void
Function called when the page changes.
Type
(details: PageChangeDetails) → void
Parameters
details – { page: number; pageSnapPoint: number }
Returns
void
slideCountnumber
The total number of slides.
Useful for SSR to render the initial ating the snap points.
allowMouseDrag?boolean
Whether to allow scrolling via dragging with mouse.
Default
false
autoplay?boolean | { delay: number; }
Whether to scroll automatically. The default delay is 4000ms.
Type
boolean | { delay: number; }
Default
false
autoSize?boolean
Whether to enable variable width slides.
Default
false
dir?"ltr" | "rtl"
The document's text/writing direction.
Type
"ltr" | "rtl"
Default
"ltr"
id?string
The unique identifier of the machine.
ids?object
The ids of the elements in the carousel. Useful for composition.