Skip to content

Skeleton

Pro

A placeholder in the shape of loading content, pure CSS with pulse or shimmer. Not an M3 component (@windmorph/react-pro).

import { Skeleton, SkeletonGroup } 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 19 props below

Skeleton 11 props

  • varianttype "rectangle" | "circle" | "text"default "rectangle"

    The shape: rectangle (full width and 96px tall) or circle (40px), sized with classes; or text, lines as tall as the typescale role's line height (lines of them, the last of several 60% wide).

  • ratiotype number | `${number}/${number}`

    A rectangle's aspect ratio (16/9, "4/3", 1): it takes that shape at its width instead of the 96px height, standing for a picture, a video or a card's image before it loads, so nothing moves when it arrives. Rectangles only: a circle is always 1:1, and ignores it. In a flex row that stretches its items, align it to the start (self-start), or the row's height wins over the ratio.

  • cornertype "none" | "extra-small" | "small" | "medium" | "large" | "extra-large" | "full"default "small" (extra-small for text lines, full for circles)

    Corner from the M3 shape scale, measured on the visible bar.

  • colortype "surface-container-highest" | "surface-container-high"default "surface-container-highest"

    The fill's colour role: surface-container-highest reads on every surface up to surface-container; surface-container-high is a subtler fill for surface and surface-container-low.

  • animationtype "none" | "pulse" | "shimmer"default "pulse"

    Overrides the animation set by the enclosing SkeletonGroup. Left out, it follows the group, or pulses outside one.

  • reftype Ref<HTMLSpanElement>

    The placeholder's <span>. Its other props (id, style, data-*) go to it too.

  • typescaletype "display-large" | "display-medium" | "display-small" | "headline-large" | "headline-medium" | "headline-small" | "title-large" | "title-medium" | "title-small" | "body-large" | "body-medium" | "body-small" | "label-large" | "label-medium" | "label-small"default "body-medium"

    The type-scale role of the text it stands in for.

  • linestype numberdefault 1

    Number of lines; the last of several is 60% wide.

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

SkeletonGroup 8 props

  • labeltype stringRequired

    What is loading, read once by assistive technology, for example "Loading businesses". Its live region goes into the page first and the label follows a moment later, so it's announced when the group appears after the page has loaded.

  • animationtype "none" | "pulse" | "shimmer"default "pulse"

    The animation of every skeleton inside.

  • astype "div" | "section" | "ul" | "li"default "div"

    The element to render. With li the group is a list item holding the label and a busy div, since a list may hold only list items.

  • childrentype ReactNode

    The skeletons (and anything else) in the region.

  • reftype Ref<HTMLElement>

    The busy element. Its other props (id, style, aria-*, data-*) go to it too.

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

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.

  • Variant: rectangle, circle, text

    Built

    Variant · Variants, Animations

  • Animation: pulse, shimmer, none

    Built

    Configuration · Animations

  • Colour: surface-container-highest and surface-container-high

    Built

    Configuration · Variants

  • Text lines sized to the type scale

    Built

    Configuration · Variants, Cards

  • A picture's or video's shape (ratio)

    Built

    Configuration · Ratios

  • Placeholder for a list of cards

    Built

    Use case · Cards

M3 Expressive specs

Shape
rounded-corner-small
Variants
rectangle, text, circle

Theming & tokens

  • The fill is surface-container-highest (or surface-container-high with color="surface-container-high"), so it follows every theme, mode and contrast level.
  • A rectangle is 96px tall unless its class sets a height; ratio ("16/9", "4/3", 1) gives it the shape of the picture or video it stands for at its width instead, so nothing moves when that arrives.
  • Corners come from the shape scale (corner); text lines take the line height of a type-scale role, and a line's corner is measured on its visible bar.
  • The pulse and the shimmer ease on the slow effects spring. The shimmer's highlight is on-surface at the hover state-layer opacity.
  • Set the tokens below on a skeleton or any ancestor. Each skeleton carries data-tokens="wm-skeleton", with data-color and data-corner picking the defaults, so a token set on a parent overrides every colour and corner. skeletonStyles no longer has color or corner variants: the tokens hold them.
Skeleton tokens
VariableDefaultPaints
--wm-skeleton-fillvar(--md-sys-color-surface-container-highest)Varies with color.The placeholder: surface-container-highest, or surface-container-high with `color="surface-container-high"`.
--wm-skeleton-cornervar(--md-sys-shape-corner-small)Varies with corner.The corners, measured on the visible bar: the `corner` prop (small; extra-small for text lines, full for circles).
--wm-skeleton-highlightcolor-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-state-layer-opacity) * 100%), transparent)The shimmer’s sweep: on-surface at the hover state-layer opacity.
--wm-skeleton-period1sHow long each pulse takes (a sweep takes 1.5 times as long). M3 has no token for a loop’s period, so it is the component’s own.