Skip to content

Carousel

A horizontal row of items users scroll through, either several cards at a time or one slide per view. Comes with previous and next buttons, dots, faded edges and optional autoplay.

// Plain markup
import { Carousel, CarouselControls, CarouselDots, CarouselItem, CarouselNext, CarouselPrevious, CarouselTrack, useCarousel } from "@shavin/ui";

Card track with controls

Featured Primitives

Foundation

Design tokens

Raw values and semantic names, so themes switch in one place.

Components

Accessible primitives

94 primitives with keyboard and screen reader support.

Shavin FX

Shaders

WebGL shader canvases for backgrounds.

AI tooling

MCP server

Gives AI agents the real props and tokens to build with.

Studio

Studio canvas

Compose screens by drag and drop.

Component Source
<Carousel variant="cards" alignToContainer="lg" fadeEdges>
  <div className="flex items-center justify-between mb-4">
    <Heading size="md">Featured Items</Heading>
    <Carousel.Controls>
      <Carousel.Previous />
      <Carousel.Next />
    </Carousel.Controls>
  </div>
  <Carousel.Track gap="4">
    {items.map((item, idx) => (
      <Carousel.Item key={idx} className="w-[280px]">
        <Card className="p-4 flex flex-col gap-2">
          <Heading size="sm">{item.title}</Heading>
          <Text size="sm" color="subtle">{item.desc}</Text>
        </Card>
      </Carousel.Item>
    ))}
  </Carousel.Track>
</Carousel>

Slider mode

Foundation

Design tokens

Raw values and semantic names, so themes switch in one place.

Components

Accessible primitives

94 primitives with keyboard and screen reader support.

Shavin FX

Shaders

WebGL shader canvases for backgrounds.

AI tooling

MCP server

Gives AI agents the real props and tokens to build with.

Studio

Studio canvas

Compose screens by drag and drop.

Component Source
<Carousel variant="slider" onSlideChange={setSlide}>
  <Carousel.Track>
    {slides.map((slide, idx) => (
      <Carousel.Item key={idx}>
        <div className="h-48 rounded-[var(--radius-panel)] bg-surface-hover/40 border border-hairline flex items-center justify-center p-6 text-center">
          <Heading size="lg">{slide.title}</Heading>
        </div>
      </Carousel.Item>
    ))}
  </Carousel.Track>
  <Carousel.Dots count={5} />
</Carousel>

Props

PropTypeDefaultDescription
alignToContainerContainerSizenoneAlignment of track start/end to a standard Shavin container size. Default "none".
fadeEdgesbooleanfalseWhether to render subtle gradient edge fade overlays on the track boundaries. Default false.
scrollStepnumber340Custom scroll step in pixels for cards variant. Default 340.
autoPlayIntervalnumberdisabledAuto-scroll interval in ms (slider mode only). Default disabled.
onSlideChange(index: number) => void—Callback fired when active slide index changes.
variant"slider" | "cards""cards"—
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font