Skip to content

Carousel

Expressive

A scrollable row of items that resize along keylines: multi-browse, uncontained, multi-aspect, hero or full-screen.

import { Carousel } from '@windmorph/react';

Props

By name or description, across the 25 props below

Events

Text

Also accepts the root element's HTML attributes (id, data-*, event handlers).

Tokens

M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.

Carousel tokens (md-comp-carousel)
VariableDefaultPaints
--md-comp-carousel-item-container-shapevar(--md-sys-shape-corner-extra-large)Each item's corners (not the full-screen variant's, which are square).

Spec status

Built to the M3 Expressive carousel spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.

  • Multi-browse

    Built

    Variant · Multibrowse

  • Uncontained

    Built

    Variant · Variants

  • Uncontained multi-aspect ratio

    Built

    Variant · Layouts

  • Hero

    Built

    Variant · Hero

  • Center-aligned hero

    Built

    Variant · Variants

  • Full-screen

    Built

    Variant · Layouts

  • Items that open something

    Built

    Use case · Actions

  • Vertical carousels

    Extension

    orientation="vertical" lays out any variant in a column; the spec shows only full-screen carousels vertically.

  • Parallax

    Not built

    There's no parallax helper; each item's visible size is exposed as --m3-carousel-item-size to build one.

Bundle size

Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.

  • Carousel: 22.8 kB

M3 Expressive specs

Shape
rounded-corner-extra-large
Variants
multi-browse, uncontained, multi-aspect, hero, full-screen

Differences from Compose

  • The keylines are a TypeScript port of Compose's carousel package; with 360px, a 186px preferred size and 8px spacing that gives 186 · 118 · 40, mirrored at the end, as Compose does. Uncontained items don't follow keylines: as the spec says, they keep one size and flow past the edge, where Compose shrinks and crops them.
  • Compose drives a pager; here the carousel scrolls natively and a library-owned mask layer inside each item is translated and clipped on every scroll frame, so the root and slots are never transformed and nothing re-renders while scrolling.
  • Hero and full-screen snap one item at a time; a multi-browse fling crosses several items and then snaps; uncontained and multi-aspect scroll freely unless snap="item".
  • Padding follows the spec: 16px before and after the items and 8px across them (uncontained and multi-aspect: 16px before only; full-screen: none), set with contentPadding. As in Compose, items scroll over the start and end padding (the spec: items "bleed over the padding on each side when scrolling"), so the 16px after the items shows only at the end of the scroll, where the last item rests. Unlike Compose, only the large and medium items give up the padding at the ends, so small items never drop below the spec's 40px minimum.
  • Items are masked with 28px (extra-large) corners, tightening to 20px while pressed (full-screen items have none), on a surface fill, and spacing defaults to 8px (16px full-screen). Deviations: no parallax helper, and before hydration items render unmasked at the preferred size.