Spinner
An indeterminate loading indicator.
- The root is a role="status" live region (override role, e.g. role="none" inside a region that already announces the busy state, or role="progressbar", which label names unless you pass aria-label or aria-labelledby).
- The region mounts **empty** and receives its label (default "Loading") one animation frame after the spinner is shown, so screen readers announce it (a live region that mounts with its content is often not announced). With labelVisible the label also shows next to the ring from that frame on.
- delay holds back the ring and the label for that many milliseconds (the region mounts at once), so a fast load does not flash the spinner. The root's data-state is delayed, then shown.
- labelPosition places the visible label before, after, above or below the ring, and the root carries it as data-label-position. label takes any content, not only text.
- size falls back to the size of a surrounding SpinnerContextProvider (a parent that sizes the spinners it holds), then medium.
- appearance="inverted" draws the spinner in the current text color, for a primary Button or another brand or inverted surface. The root carries data-appearance.
- The ring is decorative (aria-hidden) and spins slower for reduced motion. In forced-colors mode its arc is drawn in Highlight on a Canvas track, so the rotation stays perceivable.
Examples
Default
export const Default: Story = {};Sizes
export const Sizes: Story = {
render: ({ size: _size, label: _label, ...args }) => (
<div className="flex items-center gap-4">
{sizes.map(([size, label]) => (
<Spinner key={size} size={size} label={label} {...args} />
))}
</div>
),
};With Label
export const WithLabel: Story = {
args: {
size: 'medium',
label: 'Loading content...',
labelVisible: true,
},
};Inverted
export const Inverted: Story = {
args: {
appearance: 'inverted',
label: 'Saving',
},
render: ({ size: _size, labelVisible: _labelVisible, ...args }) => (
<div className="flex flex-wrap items-center gap-4">
<Button appearance="primary" icon={<Spinner {...args} size="extra-small" />}>
Saving
</Button>
<div className="inline-flex items-center rounded bg-wave-inverted px-3 py-2 text-wave-inverted-foreground">
<Spinner {...args} size="small" labelVisible />
</div>
</div>
),
};Delayed
export const Delayed: Story = {
args: {
delay: 800,
label: 'Loading results',
labelVisible: true,
},
render: (args) => <DelayedDemo {...args} />,
};Label Positions
export const LabelPositions: Story = {
args: { labelVisible: true, label: 'Loading' },
render: ({ labelPosition: _position, ...args }) => (
<div className="flex flex-wrap items-center gap-8">
{labelPositions.map((position) => (
<Spinner key={position} labelPosition={position} {...args} label={position} />
))}
</div>
),
};Size Scale
export const SizeScale: Story = {
render: ({ size: _size, label: _label, ...args }) => (
<div className="flex items-center gap-4">
{spinnerSizes.map((size) => (
<Spinner key={size} size={size} label={size} {...args} />
))}
</div>
),
};Size From Context
export const SizeFromContext: Story = {
render: () => (
<SpinnerContextProvider size="huge">
<div className="flex items-center gap-4">
<Spinner label="Provider size" />
<Spinner size="tiny" label="Own size" />
<Spinner
labelVisible
label={
<>
Loading <strong>results</strong>
</>
}
/>
</div>
</SpinnerContextProvider>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
size | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | 'extra-tiny' | 'tiny' | 'huge' | No | 'medium', or the size of the surrounding `SpinnerContextProvider` | Size of the spinner: |
label | React.ReactNode | No | 'Loading' | What the spinner's status region announces (and what shows with |
labelVisible | boolean | No | Whether the label text is visually displayed alongside the spinner. | |
labelPosition | 'before' | 'after' | 'above' | 'below' | No | 'after' | Where the visible label sits relative to the ring: |
appearance | 'primary' | 'inverted' | No | 'primary' |
|
delay | number | No | 0 | Milliseconds to wait before the ring and the label appear, so a fast load does not flash the spinner. The status region is mounted (empty) at once and announces the label once shown. A non-finite or negative value means 0. |
role | React.AriaRole | No | 'status' | Role of the root; a forwarded |
ref | React.Ref<HTMLSpanElement> | No | ||
slotProps | { spinner?: SlotPart<'span'>; label?: SlotPart<'span'> } | No | Props for the elements the spinner draws inside its root, by part, merged into each part's own (Fluent UI's |
Any other prop is passed to the element it renders (HTMLSpanElement).
Parts
spinnerlabel
Stable class names
| Part | Class |
|---|---|
root | wave-spinner |
spinner | wave-spinner__spinner |
label | wave-spinner__label |