Spinner
A CSS-only animated indicator for loading states.
Import
import { Spinner } from '@matix/components/spinner';Usage
Loading…
Sizes
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />With Label
Spinner announces its label ("Loading…" by default) through a role="status" region. Set label to say what loads.
<Spinner label="Loading invoices…" />If visible text already says what loads, set label={null}. The spinner is then decorative. Put role="status" on the wrapper, so screen readers announce the visible text one time.
import * as stylex from '@stylexjs/stylex';
const layout = stylex.create({
inline: { display: 'inline-flex', alignItems: 'center', gap: 8 },
});
<div role="status" {...stylex.props(layout.inline)}>
<Spinner size="sm" label={null} />
<span>Loading…</span>
</div>;Inside a Button
import { Button } from '@matix/components/button';
<Button disabled>
<Spinner size="sm" label={null} />
Saving…
</Button>;Custom Styles
import * as stylex from '@stylexjs/stylex';
import { colors } from '@matix/tokens';
const custom = stylex.create({
primary: { color: colors.primary },
});
<Spinner sx={custom.primary} />;API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Spinner size |
label | string | null | 'Loading…' | Text that screen readers announce. null makes the spinner decorative |
sx | StyleXStyles | — | StyleX style override |
All other HTML attributes, such as id and aria-*, go to the root element.
Accessibility
- Renders a
<span>withrole="status". Thelabelis hidden text inside it, so screen readers announce it. The inner SVG hasaria-hidden="true". - With
label={null}, the spinner hasaria-hidden="true"and no role. Use it when visible text already announces the state. - Under
prefers-reduced-motion: reduce, the spinner turns at half speed. It does not stop: a still arc does not tell the user that work is in progress.
This is an RSC-safe component — it ships no JavaScript to the browser.