Spinner
Inline loading indicator that wraps a spinning lucide icon and inherits the surrounding text color.
Install
Pull Spinner from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Spinner } from "@brika/clay";import { Spinner } from "@brika/clay/components/spinner";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { Spinner } from '@brika/clay/components/spinner';
/** Bare spinner, decorative by default and marked `aria-hidden`. */
export default function SpinnerDefaultDemo() {
return <Spinner />;
}Spinner, every way
In Button
Compose the spinner inside a disabled button to communicate an in-flight action.
Sizes
All three sizes side by side, `sm` (0.875rem), `default` (1rem), and `lg` (1.25rem).
With Label
Pass `label` to wrap the spinner in a `role="status"` element with an sr-only string for screen readers.
Accessibility
- Decorative spinners must set
aria-hidden="true"so screen readers skip them, Clay applies this automatically when nolabelis provided. - Spinners that convey loading state should pass a
label, the wrapper rendersrole="status"with a visually hidden (sr-only) label so AT users hear the state. - When pairing a visible loading text next to the spinner, keep the spinner
aria-hiddenand let the visible text carry the announcement.
Theme tokens
Every CSS variable Spinner reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Spinner
without touching component code.
Spinner tokens
2 tokens--spinner-colorcolorcurrentColorcomponents.spinner.colorSpinner stroke color, defaults to `currentColor` so it inherits text color.
--spinner-sizesize1remcomponents.spinner.sizeDefault spinner dimension (width and height) for the `default` size variant.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.spinner, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"spinner": {
"color": "currentColor"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-spinner-…) — see the
chips on each token row.
API reference
Props specific to Spinner. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
- stringExtra class names merged onto the rendered SVG. Use this to override defaults or compose layout utilities, Clay merges with
tailwind-mergeso the caller's classes win on conflict. - stringOptional accessible label announcing the loading state. When provided, the spinner is wrapped in an
<output>element with an sr-only label so assistive tech announces it. When omitted, the spinner is treated as decorative and markedaria-hidden. - sizedefault
'default'SpinnerSizeVisual size of the spinner. Maps to Tailwindsize-*utilities (sm→ 0.875rem,default→--spinner-size(1rem),lg→ 1.25rem). Defaults to'default'.