Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Primitives

Spinner

An animated indicator that shows work is in progress and the page is waiting.

Selector: mui-spinner

Import
import { Spinner } from '@mushilu-san/ui/primitives';
PreviewCode

Loading example…

Overview

Spinner has role="status" and an aria-label from label (default "Loading"), so screen readers announce that work is in progress.

The graphic inside is decorative. When the user prefers reduced motion, the spin is replaced by a slower pulse, and the status text still conveys the state.

When to use

  • Waiting for a short operation where the layout does not yet know the final content.
  • Showing progress inside a Button while it is loading, or next to a region that is refreshing.

When not to use

  • Operations with a known duration. Use Progress so the user sees how far along it is.
  • Loading a whole page of content. Use Skeleton to show the shape of what is coming.

Examples

Custom label

Change label to describe what is loading, so the announcement is useful.

PreviewCode

Loading example…

Guidelines

Do

  • Set label to describe the operation, such as "Saving draft".
  • Keep the surrounding content visible while the spinner runs when possible.

Don't

  • Do not show a spinner forever. Add a timeout and an error message.
  • Do not hide the spinner with display: none while work is still running, or the status is lost.

Accessibility

Roles and attributes

ElementRoleNotes
hoststatusaria-label comes from label.
svg—aria-hidden="true", decorative.
  • Use aria-busy="true" on the region that is loading, so assistive technology knows it is updating.

API

Spinner

Selector: mui-spinner

NameTypeDefaultDescription
size'sm' | 'md' | 'lg' | 'xl''md' Spinner size: `sm` (16px) to `xl` (48px). Default `md` (24px).
color'primary' | 'inherit' | 'muted' | 'danger' | 'success' | 'warning''inherit' Spinner colour from the semantic palette. `inherit` uses the surrounding text colour.
labelstring'Loading' Text announced to screen readers while loading. Default `Loading`.

CSS parts

  • ::part(root)

Tokens

  • --mui-color-primary
  • --mui-color-text-muted
  • --mui-color-danger
  • --mui-color-success
  • --mui-color-warning