Skip to content

Shelf

Pro

One row of cards that scrolls sideways, with part of the next card showing at its end and Previous and Next at its sides for a mouse. Not an M3 component (@windmorph/react-pro).

import { Shelf, ShelfPlaceholder } 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 24 props below

Shelf 17 props

  • childrentype ReactNodeRequired

    The cards. Each is wrapped in a list item and keeps its own key.

  • pertype "wide" | "tall"default "wide"

    Cards to a line at each size of the shelf: wide for 16:9 pictures (1.35 to 6.15), tall for 9:16 ones (2.4 to 9.3). Never whole numbers, so part of the next card shows. An app sets its own through the --wm-shelf-per-line-* tokens.

  • cardWidthtype string

    A fixed card width (a CSS length) in place of a share of the row, for cards that shouldn't grow.

  • pageSharetype number

    How much of the row's visible width Previous and Next move, before the snap lands on a card's start. Under 1, so the card that peeked is still in view. Left out, the --wm-shelf-page-share token (0.85).

  • arrowsAligntype "center" | "media"default "center"

    Where the arrows sit up and down: the row's middle, or the middle of the first card's element marked data-shelf-media (its picture).

  • arrowstype booleandefault true

    Shows Previous and Next for a mouse (never for touch).

  • 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).

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Events

  • onEndReachedtype (() => void)

    Called when the row reaches its end, for an app that loads more.

Text

  • labelstype Partial<ShelfLabels>

    Words the buttons say, 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.

ShelfPlaceholder 7 props

  • childrentype ReactNodeRequired

    The placeholder cards (e.g. ten skeleton cards, enough for the widest shelf).

  • pertype "wide" | "tall"default "wide"

    Cards to a line, as the shelf it stands in for.

  • cardWidthtype string

    A fixed card width, as the shelf it stands in for.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

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.

  • Wide (16:9) cards, the arrows centred on their pictures (arrowsAlign="media")

    Built

    Variant · Wide

  • Tall (9:16) cards (per="tall")

    Built

    Variant · Tall

  • Loading, with skeleton cards (ShelfPlaceholder)

    Built

    Configuration · Loading

  • Not an M3 component

    Extension

    M3’s carousel sizes its items as a share of the row and clips them; a shelf keeps an app’s own cards untouched in a plain list, with side arrows that M3’s carousel rules out.

  • Sized by its own width

    Extension

    Cards to a line step by the shelf’s width at the library’s size classes, never whole numbers, so part of the next card always shows.

Theming & tokens

Set the tokens below on the shelf or any ancestor; set the --wm-shelf-per-line-* tokens for your own number of cards at each size. The default 8px gap and no let-out suit cards in general; cards that carry their own padding set --wm-shelf-gap and --wm-shelf-let-out. The arrows are the side arrows the FeaturedCarousel uses, themed by its --wm-side-arrow-* tokens and the shared --wm-on-media-* ones on the Video player page. className goes on the root and aria-* on the list; style each part with classNames: root, list, item, previous, next.

Shelf tokens
VariableDefaultPaints
--wm-shelf-per-line-compact1.35Varies with per.Cards to a line in a compact (under 600px) shelf, and how much of the next shows (wide cards; `per="tall"` has its own).
--wm-shelf-per-line-medium3.15Varies with per.Cards to a line in a medium (600px) shelf, and how much of the next shows (wide cards; `per="tall"` has its own).
--wm-shelf-per-line-expanded4.15Varies with per.Cards to a line in a expanded (840px) shelf, and how much of the next shows (wide cards; `per="tall"` has its own).
--wm-shelf-per-line-large5.15Varies with per.Cards to a line in a large (1200px) shelf, and how much of the next shows (wide cards; `per="tall"` has its own).
--wm-shelf-per-line-extra-large6.15Varies with per.Cards to a line in a extra-large (1600px) shelf, and how much of the next shows (wide cards; `per="tall"` has its own).
--wm-shelf-gap8pxThe space between cards (0 for cards that carry their own padding).
--wm-shelf-padding-inline-compact12pxA compact shelf’s side padding, which the cards scroll over to the edge; the first card rests there.
--wm-shelf-let-out0pxHow far the row reaches past the shelf’s sides from 600px, so cards with their own padding line their pictures up with the page.
--wm-shelf-ring-room4pxRoom round the cards inside the scrolling row, so a focused card’s ring is never cut by its edge.
--wm-shelf-page-share0.85How much of the row Previous and Next move, before the snap lands on a card.