Skip to content

Loading indicator

Expressive

An Expressive shape that morphs while it rotates; replaces the spinning circle.

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

Props

LoadingIndicator 10 props

  • valuetype number

    Progress from 0 to 1, for a progress-driven gesture such as pull to refresh. Leave it out (the usual case) for an indeterminate indicator, which morphs through its shapes while rotating. Don't switch one indicator from indeterminate to determinate: the spec says a loading indicator never turns into a progress indicator; use a progress indicator instead.

  • varianttype "default" | "contained"default "default"

    contained draws the indicator on a primary-container circle.

  • shapestype readonly [MorphShape, MorphShape, ...MorphShape[]]

    At least two shapes (MaterialShapes names or RoundedPolygons). Defaults to Compose's sequences: seven shapes when indeterminate, circle → soft burst when determinate.

  • sizetype numberdefault 48

    The box's size in px. The spec: "Loading indicators default to 48dp, but the size is flexible. It should be between 24dp to 240dp"; the shape keeps its ratio to the box. Values outside that range are clamped.

  • reftype Ref<HTMLDivElement>

    Ref to the root element.

Text

  • aria-labeltype string

    Names the indicator ("Loading messages"). Required unless aria-labelledby is set.

  • aria-labelledbytype string

    The id of the visible text that names the indicator. Required unless aria-label is set.

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.

Loading indicator tokens (md-comp-loading-indicator)
VariableDefaultPaintsCompose
Default (variant)
--md-comp-loading-indicator-active-indicator-colorvar(--md-sys-color-primary)The morphing shape.LoadingIndicatorTokens.ActiveIndicatorColor
Contained (variant)
--md-comp-loading-indicator-contained-active-indicator-colorvar(--md-sys-color-on-primary-container)The morphing shape of a contained indicator.LoadingIndicatorTokens.ContainedActiveColor
--md-comp-loading-indicator-contained-container-colorvar(--md-sys-color-primary-container)The round container behind it.LoadingIndicatorTokens.ContainedContainerColor

Spec status

Built to the M3 Expressive loading indicator 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.

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.

  • LoadingIndicator: 24.0 kB

M3 Expressive specs

Shape
rounded-corner-full
Variants
default, contained

Differences from Compose

  • A 48px box with full corners by default. size sets it in px within the spec's 24–240px range (values outside it are clamped), or a size-* class resizes it. The shape scales with the box, kept square and centred by the viewBox.
  • variant is default (a primary indicator) or contained (on-primary-container on a primary-container circle).
  • Indeterminate loops Compose's seven shapes, springing to the next every 650ms with a quarter-turn of rotation; determinate morphs a circle into a soft burst as value rises. shapes overrides the sequence with two or more MaterialShapes names or RoundedPolygons.
  • Every frame is a pure function of elapsed time (tested against Compose's numbers). The indeterminate loop writes the path and the inner <g> rotation straight to the SVG on Motion's animation frames, so it causes no React renders.