Skip to content

Spinner

FeedbackSince 0.2.0

An indeterminate loading indicator. The host is a role="status" region (implicitly aria-live="polite") containing a decorative rotating icon and a localized label. It provides:

  • a label that is announced politely when the spinner appears;
  • an optional delay, so fast operations never flash a spinner;
  • a static icon under reduced motion.
  • Accessible statusA status role with a label, visible or for screen readers only.
  • Show delayWaits before it appears, so quick loads never flash a spinner.
  • Three sizesSmall, medium, and large, with an icon you can replace.
  • Reduced motionRespects the reduced motion preference of the user.

Use it for

  • Short waits of unknown duration (loading a panel, saving).
  • Inside a busy region (aria-busy) as the announced status next to Skeleton placeholders.

Use something else for

  • Measurable progress: use ProgressBar.
  • Blocking the whole page: prefer skeletons or inline progress.
  • Inside buttons as the only feedback without a label.
Anatomy
<div class="aui-spinner aui-spinner--{size} [aui-spinner--pending]" role="status">
<svg class="aui-icon aui-spinner__icon" aria-hidden="true"></svg> (after the delay)
<span class="aui-spinner__label [aui-spinner__label--hidden]">Loading</span>
</div>

Use the bar above each frame to switch theme, density, direction, and locale.

The part of the Status center showcase that uses Spinner. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Feedback showcase: a status center with alerts, inline messages, toasts, a progress bar
// driven by a simulated job, spinners, and skeletons while content loads.
import { Alert } from '@absoluteui/components/alert';
import { Button } from '@absoluteui/components/button';
import { InlineMessage } from '@absoluteui/components/inline-message';
import { ProgressBar } from '@absoluteui/components/progress-bar';
import { Skeleton } from '@absoluteui/components/skeleton';
import { Spinner } from '@absoluteui/components/spinner';
import { Toaster, toast } from '@absoluteui/components/toast';
import { action, choice, createShowcase, hostIn, section, toggle, wait } from './kit.js';
type Tone = 'info' | 'success' | 'warning' | 'error';
const sc = createShowcase({
title: 'Status center',
description: 'Alerts, inline messages, toasts, progress, spinners, and skeletons, each with the right live-region behavior.',
});
Toaster.create({ position: 'bottom-end', max: 3, duration: 5000 });
let tone: Tone = 'info';
const alerts = section(sc, 'Alerts', ['alert']);
const alert = Alert.create(hostIn(alerts), {
tone: 'warning',
title: 'Payroll closes Friday',
message: 'Approve all timesheets by Thursday 17:00 to include them in this month.',
dismissible: true,
actions: [{ label: 'Review timesheets', value: 'review', variant: 'primary' }, { label: 'Remind me later', value: 'later' }],
});
sc.listen(alert.host, ['aui-action', 'aui-dismiss'], 'alert');
const inline = section(sc, 'Inline messages', ['inline-message']);
(['info', 'success', 'warning', 'error'] as const).forEach((t) =>
InlineMessage.create(hostIn(inline), { tone: t, message: { info: 'Changes are saved automatically.', success: 'Profile updated.', warning: 'Your certificate expires in 12 days.', error: 'The export failed. Try again.' }[t] }),
);
const progressSection = section(sc, 'Progress', ['progress-bar']);
const bar = ProgressBar.create(hostIn(progressSection), { label: 'Exporting 1,200 records', value: 0, max: 100, showValue: true, announceComplete: true, description: 'You can keep working while the export runs.' });
ProgressBar.create(hostIn(progressSection), { label: 'Connecting to the bank', value: null });
const spinnerSection = section(sc, 'Spinners', ['spinner']);
const spinners = hostIn(spinnerSection);
spinners.className = 'sc-row';
(['sm', 'md', 'lg'] as const).map((size) => Spinner.create(hostIn(spinners), { size, label: `Loading (${size})`, showLabel: size === 'lg' }));
const loading = section(sc, 'Loading content', ['skeleton']);
const card = hostIn(loading);
card.className = 'sc-skeleton-card';
const skeletons = [Skeleton.create(hostIn(card), { shape: 'circle', width: '3rem', height: '3rem' }), Skeleton.create(hostIn(card), { lines: 3 })];
Skeleton.markBusy(card, true);
const toasts = section(sc, 'Toasts', ['toast']);
const toastIntro = document.createElement('p');
toastIntro.textContent = 'Toasts appear at the bottom end of the page, at most three at a time, and close after five seconds. Choose the tone in the options; Run export ends with a toast that has an action.';
toasts.append(toastIntro);
const toastRow = hostIn(toasts);
toastRow.className = 'sc-row';
const showToast = Button.create({ text: 'Show toast', variant: 'secondary' }, document);
toastRow.append(showToast.element);
const runExport = async (): Promise<void> => {
bar.update({ tone: 'default' });
for (let v = 0; v <= 100; v += 10) {
bar.setValue(v);
await wait(250);
}
bar.update({ tone: 'success' });
toast({ tone: 'success', title: 'Export ready', message: 'export-2026-11.csv is ready to download.', action: { label: 'Download', onAction: () => { sc.log('toast action: download'); } } });
sc.log('export finished');
};
action(
sc,
'Run export',
() => {
void runExport();
},
['progress-bar', 'toast'],
);
showToast.element.addEventListener('click', () => {
toast({ tone, message: { info: 'Three people joined your team.', success: 'Settings saved.', warning: 'You are offline. Changes will sync later.', error: 'Could not reach the server.' }[tone] });
sc.log('toast shown', { tone });
});
action(sc, 'Show alert again', () => {
alert.update({ title: 'Payroll closes Friday' });
if (!alert.host.isConnected || alert.host.hidden) alerts.append(alert.host);
alert.host.hidden = false;
}, ['alert']);
choice<Tone>(
sc,
'Toast tone',
[
{ value: 'info', label: 'Info' },
{ value: 'success', label: 'Success' },
{ value: 'warning', label: 'Warning' },
{ value: 'error', label: 'Error' },
],
'info',
(t) => {
tone = t;
},
['toast'],
);
toggle(sc, 'Content loaded', false, (loaded) => {
Skeleton.markBusy(card, !loaded);
if (loaded) {
for (const s of skeletons) s.destroy();
card.textContent = 'Ada Lovelace, Engineering lead. 12 open reviews.';
}
}, ['skeleton']);
import { Spinner } from '@absoluteui/components/spinner';
const host = document.querySelector<HTMLElement>('#results-status');
if (host) {
const spinner = Spinner.create(host, { label: 'Loading results', delay: 300 });
void fetch('/api/results').finally(() => {
spinner.destroy();
});
}
import { Spinner } from '@absoluteui/components/spinner';
const host = document.querySelector<HTMLElement>('#saving');
if (host) {
Spinner.create(host, { label: 'Saving changes', showLabel: true, size: 'sm' });
}
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { Spinner } from '@absoluteui/components/spinner';
import '@absoluteui/components/spinner/style.css';
import { Spinner } from '@absoluteui/components/spinner';
import '@absoluteui/components/spinner/style.css';
const host = document.querySelector<HTMLElement>('#saving');
if (host) {
const spinner = Spinner.create(host, { label: 'Saving changes', showLabel: true, delay: 200 });
void fetch('/api/save', { method: 'POST' }).finally(() => {
spinner.destroy();
});
}
More usage
import { Spinner } from '@absoluteui/components/spinner';
const host = document.createElement('div');
document.body.append(host);
const spinner = Spinner.create(host, { label: 'Loading results', delay: 300 });
spinner.destroy();

Using Angular? See Spinner for Angular.

Spinner.create(host: HTMLElement, options?: SpinnerOptions): Spinner

Global configuration key: spinner (see Configuration).

Option Type Default Description
label string Announced (and optionally visible) label. Default: localized “Loading”.
showLabel boolean false Show the label visibly; otherwise it is visually hidden but announced.
icons Partial<{ spinner: IconRef }> Icon slot overrides.
size 'sm' | 'md' | 'lg' "md" Icon size. Globally configurable.
delay number 0 Milliseconds (integer 0..60000) before the content is shown. Globally configurable. Set at creation only.
locale string "en-US" Message locale for the default label. Globally configurable. Inherited from common configuration.
Property Type Description
host HTMLElement The role=“status” host.
visible boolean Whether the delay elapsed and content is rendered.
Method Description
update(options: Partial<SpinnerOptions>): void Merge and apply options (delay cannot change).
destroy(): void Cancel a pending delay; remove rendering, role, and subscriptions.

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-spinner Host (role=“status”).
aui-spinner--sm | --md | --lg Size modifiers.
aui-spinner--pending Delay not yet elapsed.
aui-spinner__icon Decorative rotating icon (aria-hidden).
aui-spinner__label Label text.
aui-spinner__label--hidden Visually hidden label.
Slot Default icon
spinner spinner

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-color-primary | --aui-color-text | --aui-font-family-sans | --aui-font-size-sm | --aui-icon-size-lg | --aui-icon-size-md | --aui-icon-size-sm | --aui-line-height-tight | --aui-space-2

TypeScript definitions
type SpinnerSize = 'sm' | 'md' | 'lg';
interface SpinnerIcons { spinner: IconRef }
interface SpinnerConfig { size: SpinnerSize; delay: number }
interface SpinnerOptions extends Partial<SpinnerConfig> {
label?: string;
showLabel?: boolean;
locale?: string;
icons?: Partial<SpinnerIcons>;
}

Pattern: ARIA status live region (role=“status”, implicit aria-live=“polite”).

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
None Any Not focusable; no keyboard interaction.
Element Role
host status
icon none (aria-hidden=true)
Attribute Element Value
role host status
aria-hidden icon true

Not focusable. Focus is never moved.

Criterion Level Note
1.3.1 Info and Relationships A
2.2.2 Pause, Stop, Hide A
2.3.3 Animation from Interactions AAA
4.1.3 Status Messages AA

Automated test results: Accessibility and compliance.

  • The status region is rendered empty until the delay elapses; inserting the label then triggers a polite announcement.
  • Rotation stops under prefers-reduced-motion or animation: none; the static icon and the label remain.
  • The label is visually hidden by default and always remains in the accessibility tree.
  • Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/spinner 31.7 kB 11.1 kB 9.8 kB 0.5 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
Spinner.create() < 1 ms in headless Chromium

Tested scale: Tested with one spinner per region; many simultaneous spinners are an anti-pattern.

No DOM listeners; one timer while pending and one configuration subscription. The rotation is a compositor-friendly transform animation. Target: under 1 ms per Spinner.create in headless Chromium (not yet covered by the e2e performance suite).

Measured run times: Performance.

States

pending (the delay has not elapsed; the status region is empty) and visible.

State transitions
From Trigger To
(created, delay: 0) create visible
(created, delay > 0) create pending
pending delay elapses visible (label inserted and announced)
pending / visible destroy() removed; a pending timer is cancelled
Accessibility notes
  • The region exists from creation and is empty while pending. Inserting the label into the existing region triggers a polite announcement.
  • With delay: 0 the region and its content appear in the same task, and some screen readers may not announce it. Use a delay, or create the spinner on an empty host that is already in the page.
  • Rotation stops under prefers-reduced-motion: reduce or animation: 'none'. The static icon and the label remain.
  • Manual screen-reader verification is pending.
Responsive behavior

Inline-level. The icon size follows size; the visible label wraps with the surrounding text.

Right-to-left

Logical gap between the icon and the label. The rotation direction is not mirrored.

Theming

The icon uses color-primary and the label uses color-text. Forced-colors mode uses CanvasText.

Global configuration
configureAbsoluteUI({ components: { spinner: { size: 'sm', delay: 300 } } });

size applies to existing instances immediately; delay applies to new instances.

Component configuration

Instance options override global and theme defaults. delay is init-only; all other options are dynamic.

Icons

icons.spinner (default spinner).

Security

The label uses textContent. No inline styles; the visually hidden label uses a CSS class.

Data handling

No persistence, network access, or telemetry.

Supported data scale

One spinner per loading region. Many simultaneous spinners are an anti-pattern, because each one is a live region.

Edge cases
  • Destroying the spinner before the delay elapses means it never renders, which is the intended behavior for fast operations.
  • Changing the label while visible updates the region text, and screen readers announce the new label.
  • The default label follows the configured locale; register translations with registerMessages('spinner', locale, { loading }).
Errors
Code Category Cause
SPINNER_OPTIONS configuration Empty label.
CFG_INVALID_VALUE configuration Invalid size, or delay outside 0-60000 or not an integer.
CFG_INIT_ONLY configuration update({ delay }) on an existing instance.

A failed construction leaves the host untouched.

Known limitations
  • The announcement for delay: 0 depends on the screen reader (see Accessibility notes).
  • delay is init-only.
  • Manual screen-reader verification is pending.
Unsupported scenarios
  • Determinate progress.
  • HTML in the label.