Spinner
BasicFeedback
<co-spinner>Spinner shows that something is loading when the wait is short or its length is unknown.
import { Spinner } from 'health-components';
Examples
Overview
Usage
<Spinner label="Checking coverage" /> <Spinner size="lg" tone="ai" />
When to use
- Inside buttons (Button loading) and for waits under a few seconds.
When not to use
- Known layouts that load: Skeleton. Long jobs: ProgressBar.
Variants and states
| Variant | What it is |
|---|---|
| sm | 14px. |
| lg | 36px. |
| ai | AI purple top, for AI work. |
Accessibility
- role status with a label; slows under prefers-reduced-motion.
Do and don't
- Do: "Checking coverage with Aetna" next to it.
- Don't: A spinner with no text for more than 2 seconds.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'lg' | 'sm' | 'sm' | 'lg' |
tone | 'primary' | 'ai' | 'primary' | 'primary' | 'ai' |
label | string | "Loading" | Accessible name announced by screen readers |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-spinner>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-spinner size="…" tone="…" [defaultValue]="defaultValue"></co-spinner>
| Kind | Name | Description |
|---|---|---|
| attribute | size | 'sm' | 'lg'; default 'sm' |
| attribute | tone | 'primary' | 'ai'; default 'primary' |
| attribute | label | Accessible name announced by screen readers; default "Loading" |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus |