Skip to content

Featured carousel

Pro

The large carousel at the top of a media or store page: one slide in front with whole slides set back beside it, moved by a swipe, side arrows or keys, and by itself only with a Pause control. Not an M3 component (@windmorph/react-pro).

import { FeaturedCarousel, FeaturedCarouselSlide, FeaturedCarouselPlaceholder, useFeaturedCarouselSlide } from '@windmorph/react-pro';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 38 props below

FeaturedCarousel 24 props

  • childrentype ReactNodeRequired

    FeaturedCarouselSlide elements.

  • indextype number

    The current slide (controlled).

  • defaultIndextype numberdefault 0

    The slide current at first (uncontrolled).

  • looptype booleandefault true

    Previous, Next, the keys and the timer go round from the last slide to the first.

  • autoAdvancetype boolean | { interval?: number; }default false

    Moves on by itself, within WCAG 2.2.2: true (7 seconds a slide) or { interval } in milliseconds. It waits while a mouse is over the slides, while less than half is in view, while the tab is hidden and while a slide holds it; it stops, until Play is pressed, once the person moves it or the keyboard's focus comes in; never under reduced motion.

  • pausedtype boolean

    Whether the Pause control has stopped everything that moves by itself, the slides and media in a slide (controlled). A move by hand, or the keyboard's focus coming in, stops only the slides, until Play: media in the slide the person went to goes on playing.

  • defaultPausedtype booleandefault false

    Whether it starts stopped (uncontrolled).

  • arrowstype booleandefault true

    Previous and Next at the sides, for a mouse.

  • indicatortype booleandefault true

    The dots under the slides.

  • maxDotstype numberdefault 20

    Past this many slides a count ("3 of 30") stands in for the dots.

  • previousIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Replaces Previous's chevron; it should point left (it mirrors in right to left).

  • nextIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Replaces Next's chevron; it should point right (it mirrors in right to left).

  • pauseIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Replaces the Pause control's pause icon.

  • playIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Replaces the Pause control's play_arrow icon.

  • reftype Ref<HTMLElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Events

  • onIndexChangetype ((index: number, details: { cause: FeaturedCarouselCause; }) => void)

    Called when another slide becomes current, with what moved it.

  • onPausedChangetype ((paused: boolean) => void)

    Called when the Pause control (or Play) stops or starts everything.

Text

  • labelstype Partial<FeaturedCarouselLabels>

    Words the carousel says, with English defaults. A LabelsProvider sets them for the whole app.

  • aria-labeltype string

    One of aria-label or aria-labelledby is required.

  • aria-labelledbytype string

    One of aria-label or aria-labelledby is required.

FeaturedCarouselSlide 7 props

  • textValuetype stringRequired

    The slide's name, said with its place after a move by hand ("City after dark, 2 of 4").

  • mediatype boolean

    It holds something that moves by itself (a video): the carousel then has its foot and Pause control from the first paint, even with one slide.

  • childrentype ReactNode

    Anything: a picture, words, links, buttons, a video.

  • reftype Ref<HTMLDivElement>

    Ref to the slide's element.

  • idtype string

    The slide's id.

FeaturedCarouselPlaceholder 7 props

  • childrentype ReactNode

    What stands in the slide's place: a skeleton while loading, or a notice and Try again.

  • foottype booleandefault true

    The 48px foot under the slide, as a carousel with dots or a Pause control has.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Hooks

useFeaturedCarouselSlide

useFeaturedCarouselSlide signature
useFeaturedCarouselSlide(): FeaturedCarouselSlideState

Inside a FeaturedCarouselSlide: whether it is current, whether things may move, and the timer.

Returns FeaturedCarouselSlideState

  • currenttype booleanRequired

    This slide is the current one.

  • mayMovetype booleanRequired

    Things may move by themselves now: this slide is current, the Pause control hasn't stopped them, there's no reduced motion, the carousel is in view and the tab visible.

  • holdtype () => () => voidRequired

    Holds the timer (while a video plays, say); call what it returns to let it go.

  • nexttype () => voidRequired

    Moves the carousel on now (when a video ends, say), unless the person moved it by hand.

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • Slides with a link and buttons, kept clear of the side arrows

    Built

    Use case · Slides

  • Moving by itself, with the Pause control (autoAdvance)

    Built

    Configuration · Auto

  • A slide that plays a video (media, useFeaturedCarouselSlide)

    Built

    Use case · Auto

  • Loading and failed (FeaturedCarouselPlaceholder)

    Built

    Configuration · Loading

  • Not an M3 component

    Extension

    M3’s carousel doesn’t move by itself and has no Previous and Next, indicator or controls inside an item; this one follows the APG’s auto-rotating carousel, with the core carousel’s 28px item corner and words.

  • Moving by itself within WCAG 2.2.2

    Extension

    Off unless asked; one Pause control stops the slides and any media in them, keyboard focus or a move by hand stops it until Play, and reduced motion keeps it still.

Theming & tokens

Set the tokens below on the carousel or any ancestor. --wm-featured-carousel-control-inset is published for your slide content: the arrows' distance from the edge, which the wm-featured-carousel-content utility uses as padding so words stay clear of them. The side arrows, shared with Shelf, take the --wm-side-arrow-* tokens below, and their colours, blur and focus ring the shared --wm-on-media-* ones on the Video player page. className and aria-* go on the root, the named region; style each part with classNames: root, frame, viewport, slide, previous, next, foot, indicator, dot, progress, count, pause.

FeaturedCarousel tokens
VariableDefaultPaints
--wm-featured-carousel-slide-width-compact88%A slide’s width in a compact carousel (under 600px), of the row.
--wm-featured-carousel-slide-ratio-compact4 / 5A slide’s shape in a compact carousel; a least height, so longer words lengthen it.
--wm-featured-carousel-slide-width-medium90%A slide’s width in a medium carousel (600px), of the row.
--wm-featured-carousel-slide-min-height-medium28remA slide’s least height in a medium carousel.
--wm-featured-carousel-slide-ratio-expanded16 / 9A slide’s shape from 840px.
--wm-featured-carousel-slide-max-height70dvhThe tallest a slide grows from 840px, which sets its width by its shape: the one value that reads the window (set it for a carousel in a pane of its own).
--wm-featured-carousel-slide-side-room8remWhat a slide leaves of the row from 840px, for its neighbours to peek in.
--wm-featured-carousel-cornervar(--md-comp-carousel-item-container-shape, var(--md-sys-shape-corner-extra-large))A slide’s corners: the core carousel item’s shape (28px).
--wm-featured-carousel-fillvar(--md-sys-color-scrim)Behind a slide’s picture or video.
--wm-featured-carousel-gap-compact8pxThe space between slides in a compact carousel.
--wm-featured-carousel-gap12pxThe space between slides from 600px.
--wm-featured-carousel-padding-inline-compact16pxA compact carousel’s side padding, before the first slide and after the last.
--wm-featured-carousel-padding-block8pxThe space above and below the slides.
--wm-featured-carousel-neighbor-scale0.94How much smaller a slide beside the current one is.
--wm-featured-carousel-neighbor-brightness0.5How much darker a slide beside the current one is (darker, not fainter: faded, it washed out on a light page).
--wm-featured-carousel-neighbor-durationvar(--md-sys-motion-spring-spatial-default-duration)How long size and brightness take to hand over as the slides move (at once under reduced motion).
--wm-featured-carousel-neighbor-easingvar(--md-sys-motion-spring-spatial-default-easing)Their easing.
--wm-featured-carousel-foot-height48pxThe row under the slides that holds the dots and the Pause control.
--wm-featured-carousel-foot-gap12pxThe space between the foot’s parts.
--wm-featured-carousel-dot-size6pxA dot’s size.
--wm-featured-carousel-dot-current-width24pxThe current slide’s dot, which fills as its time runs.
--wm-featured-carousel-dot-gap6pxThe space between dots.
--wm-featured-carousel-dot-colorvar(--md-sys-color-outline)The dots, which show how many slides there are: `outline`, since `outline-variant` falls under 3:1 against the page.
--wm-featured-carousel-progress-colorvar(--md-sys-color-primary)The current dot’s fill as its time runs.
--wm-featured-carousel-dot-durationvar(--md-sys-motion-spring-effects-default-duration)How long a dot takes to widen or narrow.
--wm-featured-carousel-dot-easingvar(--md-sys-motion-spring-effects-default-easing)Its easing.
--wm-featured-carousel-control-inset56pxThe room the side arrows take at each side (their 8px inset and 48px), for slide content to keep clear of: the `wm-featured-carousel-content` utility pads by it.
Side arrow tokens (FeaturedCarousel, Shelf)
VariableDefaultPaints
--wm-side-arrow-padding4pxThe container round the 40px button: 4px makes a 48px pill.
--wm-side-arrow-inset8pxThe arrow’s distance from the start or end edge.
--wm-side-arrow-offset0pxMoves the arrows up (negative) or down from the middle of the row, e.g. level with pictures that have words under them.
--wm-side-arrow-disabled-opacity0.4The arrow that leads nowhere, kept in place and dimmed.
--wm-side-arrow-fade-durationvar(--md-sys-motion-spring-effects-default-duration)How long the arrows take to show and hide (none under reduced motion).
--wm-side-arrow-fade-easingvar(--md-sys-motion-spring-effects-default-easing)Their easing.