Loadingcomponent
Loading({ className }: { className?: string | undefined }): ReactElement| Param | Type | |
|---|---|---|
options | { className?: stringundefined } | required |
| Return | |
|---|---|
ReactElement |
Animated loading spinner shaped like a Heroicon — a faint track plus a rotating indicator arc.
- Self-contained inline SVG; the spin is driven by an inline SMIL
<animateTransform>. - The track and indicator paint from scaled steps of the current tint ladder (
--tint-70/--tint-80), so their colour follows whatever tint<Icon>(or an ancestor) sets. - Takes only
classNamelike the Heroicons, so it slots straight into<Icon icon={Loading} />to pick up icon sizing, colour, and centring.
An animated SVG spinner shaped like a Heroicon — a faint full track plus a rotating indicator arc. It takes only className, so it behaves like any other icon and is meant to be styled by <Icon>.
Things to know:
- The track and indicator paint from scaled steps of the current tint ladder (
--tint-70/--tint-80), so the faint track and brighter indicator both follow whatever tint<Icon>(or an ancestor) sets, correctly shaded. - The spin is driven by an inline SMIL
<animateTransform>, so it needs no CSS to animate. - Feed it to
<Icon>to size, colour, and centre it:<Icon icon={Loading} size="large" status="loading" />.<Icon status="loading">already uses it automatically. LOADINGis a pre-keyed<Icon icon={Loading} />element with a stablekey— drop it straight intoSuspensefallbacks and lists to avoid unnecessary reconciliation overhead.
Usage
import { Icon, LOADING, Loading } from "shelving/ui";
// Styled through <Icon>, like any other icon.
<Icon icon={Loading} size="large" />
// <Icon status="loading"> uses it for you.
<Icon status="loading" />
// Pre-keyed constant for fallbacks and lists.
<Suspense fallback={LOADING}>
<SlowComponent />
</Suspense>
{busy ? LOADING : children}Styling
Size, centring, and overall colour come from wrapping it in <Icon> — its --icon-color / --icon-size hooks and color / status / size / tint variants drive the spinner (see the Icon Styling section). On top of that, the two arcs expose their own hooks:
| Variable | Styles | Default |
|---|---|---|
--loading-track | Track (background arc) stroke | var(--tint-70) |
--loading-indicator | Indicator (moving arc) stroke | var(--tint-80) |
--loading-stroke-width | Stroke width of both arcs | 2.5 |
--loading-length | stroke-dasharray of the indicator arc | 28 100 |
Global tokens it reads — the tint-ladder steps --tint-70 / --tint-80 for the arc strokes (rebound by the color / status / tint variants on the wrapping <Icon>).