Spinner
An accessible, theme-aware loading indicator used to communicate ongoing background activity or processing.
Usage
Basic usage
import { Spinner } from '@nofinite/nui';
<Spinner />;
With size variations
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />
Sizes
The Spinner supports three predefined sizes.
<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />
Available sizes:
sm– Small indicator for inline usage (e.g., inside buttons)md– Default size for general loading stateslg– Large indicator for page-level or section-level loading
States
The spinner itself is stateless, but it is commonly used to represent a loading state in other components.
Inside a disabled button
import { Spinner, Button } from '@nofinite/nui';
<Button disabled>
<Spinner size="sm" />
Processing...
</Button>;
Behavior:
- Spinner continues animating even when the parent component is disabled.
- Communicates background work without allowing interaction.
Native Props / Composition
The Spinner renders a semantic status element and supports additional props like className.
<Spinner className="my-custom-spinner" label="Saving data" />
classNamecan be used to apply custom spacing or positioning.- The component does not accept children.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | md | Controls the visual size of the spinner |
label | string | "Loading" | Accessible text announced by screen readers |
className | string | "" | Additional class names for custom styling |
Behavior Notes
-
Uses a CSS-based rotation animation (
linear, infinite). -
Visual styling adapts to the theme via CSS variables:
--color-border--color-primary
-
Does not manage or infer loading state automatically.
<Spinner label="Fetching results" />
Accessibility
- Renders with
role="status"to announce loading changes. - Uses
aria-labelfor screen reader context. - Does not rely on color alone to convey motion.
Example:
<Spinner label="Uploading file" />
Layout
- Renders as
inline-flexby default. - Centers its animated circle internally.
- Can be wrapped in layout containers for positioning.
<div style={{ display: 'flex', justifyContent: 'center', padding: 20 }}>
<Spinner size="lg" />
</div>
Best Practices
Do
- Use
smsize for inline or button loaders. - Provide a meaningful
labelfor screen readers. - Use
lgsize for full-page or section loading states.
Don’t
- Use spinner without context for long operations.
- Replace error or empty states with a spinner indefinitely.
- Nest multiple spinners in the same visual area.