Loader
<smart-loader> renders a spinner while something loads. It takes a size and a colour, hides itself until show is true, and can be replaced application-wide through an injection token.
size and color use the shared SmartSize / SmartColor scales. <smart-list> renders it while its provider loads and <smart-input> while an async validator runs, so a loader registered through LOADER_STANDARD_COMPONENT_TOKEN changes those too. It follows the Base + Standard + Wrapper pattern: LoaderBaseComponent owns the inputs and the spinner classes, LoaderStandardComponent is the default rendering, LoaderPresetComponent the styled one.
Usage
<smart-loader [show]="loading()" [size]="size" [color]="color" />
The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.
Components
LoaderComponent (<smart-loader>)
The wrapper. Renders LoaderStandardComponent by default. When LOADER_STANDARD_COMPONENT_TOKEN is provided, it renders the injected component through NgComponentOutlet and forwards show, size, color and class to it, resolved to the names that component declares, so a custom implementation extending LoaderBaseComponent receives the class in its inherited cssClass input; an input the component does not declare is left out. Its host element is display: contents (smart:contents), so it adds no box of its own.
LoaderStandardComponent (<smart-loader-standard>)
The default implementation: while show is true, an SVG spinner (role="status", aria-label="loading") that gets its size class from size and its text colour from color, with class appended. It renders nothing while show is false.
LoaderPresetComponent (<smart-loader-preset>)
A styled, drop-in variation that renders the Preline default spinner (a bordered ring with a transparent top border). Register it through LOADER_STANDARD_COMPONENT_TOKEN (or register every preset at once with provideSmartPresets()) to restyle every <smart-loader>, or use its selector directly. The preset declares cssClass without the class alias: through <smart-loader> the class still reaches it; used directly, <smart-loader-preset> takes extra classes as [cssClass].
The ring is smart:border-3 smart:border-current smart:border-t-transparent smart:rounded-full, spinning, sized like the standard and coloured smart:text-<color>-600 with an explicit smart:dark: shade for every colour (-400 for slate, gray, zinc, neutral and stone, -500 for the others). It keeps role="status" and aria-label="loading" and adds a smart:sr-only "Loading..." text. The class recipe (preset/preset-classes.util.ts) is internal, not exported from @smartsoft001/angular.
LoaderBaseComponent (abstract)
The base directive the variations extend. It owns the inputs and the spinnerClasses signal that turns size and color into Tailwind classes, so a custom implementation only has to provide a template.
| Member | Type | Description |
|---|---|---|
spinnerClasses | Signal<string[]> | smart:animate-spin, the size class, smart:text-<color>-600, then cssClass when it is set. |
smartType | DynamicComponentType (static) | 'loader'. |
API
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
show | InputSignal<boolean> | false | Whether the spinner is visible |
size | InputSignal<SmartSize> | 'md' | One of xs, sm, md, lg, xl; maps to smart:size-4, -5, -6, -8 and -10 |
color | InputSignal<SmartColor> | 'indigo' | Any colour of the shared palette; maps to a smart:text-*-600 class |
class | InputSignal<string> | '' | Extra CSS classes on the spinner (cssClass input, alias class) |
The loader emits no outputs.
LOADER_STANDARD_COMPONENT_TOKEN
An injection token from @smartsoft001/angular. Provide a Type<LoaderBaseComponent> (for example LoaderPresetComponent or your own subclass) in your application or component providers to replace the default spinner everywhere <smart-loader> is used; provideSmartPresets() provides LoaderPresetComponent for it together with every other preset.
Source
The component lives in packages/shared/angular/src/lib/components/loader and is documented for Claude Code by the angular-components-loader skill.
SmartLoader renders a spinner while show is true and nothing otherwise. size and color use the shared SmartSize / SmartColor scales. Form inputs render it while an async validator runs, and lists while they load, so registering a loader under the loader key changes all of them.
Usage
import { SmartColor, SmartLoader, SmartSize } from '@smartsoft001/react';
const size: SmartSize = 'lg';
const color: SmartColor = 'emerald';
// Pass `loading={false}` when the request finishes; the spinner disappears.
export function LoaderUsageExample({ loading = true }: { loading?: boolean }) {
return <SmartLoader show={loading} size={size} color={color} />;
}
The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.
Exports
All from @smartsoft001/react.
| Export | Kind | What it is |
|---|---|---|
SmartLoader | component | Renders the implementation registered as components.loader on SmartProvider, SmartLoaderStandard by default. |
SmartLoaderPreset | component | Styled loader variation (preset). |
SmartLoaderStandard | component | The default loader rendering: an SVG spinner. |
useLoader | hook | The behaviour every loader variant shares: the spinner classes for size and color, with className appended. |
The preset's class helpers (getLoaderSpinnerClasses) are exported too, for a custom implementation that wants the preset look.
Props and Types
SmartLoaderProps
| Prop | Type | Default | Description |
|---|---|---|---|
show? | boolean | false | Renders the spinner while true. |
size? | SmartSize | 'md' | Spinner size. |
color? | SmartColor | 'indigo' | Spinner colour. |
className? | string | — | Classes appended to the spinner. |
SmartColor, SmartSize are described in the react-provider skill.
Replacing the Implementation
SmartLoader renders the component registered under the 'loader' key of SmartProvider's components, and SmartLoaderStandard when nothing is registered there. Every SmartLoader below the provider then renders the registered component, which receives the same props.
SmartLoaderPreset is the styled (preset) implementation: register it under the 'loader' key of SmartProvider's components, render it directly in place of SmartLoader, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.
The useLoader hook
The behaviour every loader variant shares: the spinner classes for size and color, with className appended.
| Returns | Type | Description |
|---|---|---|
spinnerClasses | string[] | The classes for size and color, with className appended. |
Styling
SmartLoaderStandardis an SVG spinner;SmartLoaderPresetis a bordered spinning ring with explicitsmart:dark:variants for every colour.
Source
The component lives in packages/shared/react/src/lib/components/loader and is documented for Claude Code by the react-components-loader skill.