Spin
Waiting indicators: size, delay, percentage and full screen mode.
When to use
Standby mode and contents
spinning controls wait and defaults to true. description specifies an explanation with text or snippet. size accepts small/medium/large. children allows you to store data under the wait layer.
| Problem | Opportunity | Example |
|---|---|---|
| Show individual status | spinning, available name |
Main indicator |
| Update fields without losing your draft | children |
Nested mode |
| Do not show short indicator | delay |
Delay |
| Replace wait pattern | indicator snippet |
Your own indicator |
| Transfer percentage | number or auto |
Percent |
| Occupy screen with standby layer | fullscreen |
Full screen mode |
In nested mode, children remain in the DOM. While waiting, the content gets inert and aria-busy; the draft is saved, the temporarily unavailable focus is processed by the component. This is different from Skeleton, which replaces children.
Delay, percentage and completion
delay is measured in milliseconds and delays the appearance of the indicator. The requested spinning blocks the nested content immediately. If you end the wait before the delay expires, the indicator will not appear.
Numeric percent must come from the application. auto simulates motion until the wait ends and does not measure network or processing. For success, error and cancellation, change the spinning according to the result of the operation; the component itself does not launch it.
Profile update saves the draft and shows a replay error. Cancellation and leaving the page are protected from late results. The fullscreen example's timer is cleared when unmounted; it is a demo, no mandatory waiting period for Spin.
fullscreen, indicator and theme
fullscreen - a fixed layer in the current DOM branch, without portal and focus trap. It is not a full-fledged modal window. Place a clear cancel action outside of blocked content or ensure that the operation completes.
indicator - passive Svelte snippet with class/style, prefixCls and percent. The general option can be set via ConfigProvider.spin. Spin.setDefaultIndicator exists, but the setter does not update already mounted instances; for a reactive and isolated setup, use provider.
classNames/styles are styled root/section/indicator/description/container; styles is set by CSS strings. Spin design tokens control the size of the dots and the height of the area. Standard indicators and available content are displayed with SSR; delay, auto and controls start working after hydration.
A non-empty local prefixCls specifies the Spin CSS classes and is passed to the custom indicator in info.prefixCls. The empty string and undefined inherit ConfigProvider.prefixCls with the -spin suffix, defaulting to ant-spin. delay, loading state and namespace CSS variables are independent of class changes. Example ConfigProvider shows inheritance.
Examples
Normal loading
Independent status with an accessible name.
<script lang="ts">
import { Spin } from '@woodger/antd';
</script>
<Spin aria-label={("Loading list")} />
Dimensions
small, medium and large.
<script lang="ts">
import { Spin } from '@woodger/antd';
const sizes = ['small', 'medium', 'large'] as const;
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 32px;
}
.item {
display: grid;
justify-items: center;
gap: 16px;
}
</style>
<div class="examples">
{#each sizes as size (size)}
<div
class="item"
><Spin
{size}
aria-label={("Loading " + String((size)) + "")}
/><span>{(size)}</span></div>
{/each}
</div>
The value is saved after loading.
Loading existing content
The draft remains in the DOM.
<script lang="ts">
import { Checkbox, Input, Spin } from '@woodger/antd';
let spinning = $state(false);
let draft = $state<string | undefined>(("The draft remains in the DOM"));
</script>
<style>
.settings { margin-bottom: 24px; }
.document {
display: grid;
gap: 16px;
min-height: 160px;
padding: 24px;
border: 1px solid var(--ant-color-border-secondary);
border-radius: 8px;
}
</style>
<div
class="settings"
><Checkbox
bind:checked={spinning}
>{("Load content")}</Checkbox></div>
<Spin {spinning} description={("Document update")} aria-label={("Document")}>
<div
class="document"
><Input
aria-label={("Draft document")}
bind:value={draft}
/><p>{("The value is saved after loading.")}</p></div>
</Spin>
Description of waiting
Description via Svelte Snippet.
<script lang="ts">
import { Spin } from '@woodger/antd';
</script>
<style>
.document {
min-height: 160px;
padding: 24px;
}
strong {
display: block;
margin-bottom: 4px;
}
</style>
{#snippet description()}<strong>
{("Data preparation")}
</strong><span>
{("This will take a few seconds.")}
</span>{/snippet}
<Spin
description={(description)}
aria-label={("Data preparation")}
><div
class="document"
>{("Section contents.")}</div></Spin>
Appearance delay
Wait 500ms and cancel explicitly.
<script lang="ts">
import { Button, Checkbox, Spin } from '@woodger/antd';
let spinning = $state(false);
</script>
<style>
.settings {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
margin-bottom: 24px;
}
.document {
min-height: 160px;
padding: 24px;
}
</style>
<div class="settings">
<Checkbox bind:checked={spinning}>{("Wait for delayed response")}</Checkbox>
<Button onclick={() => { spinning = false; }}>{("Cancel waiting")}</Button>
</div>
<Spin {spinning} delay={500} description={("We are waiting for a response")} aria-label={("Lazy loading")}>
<div class="document">{("The indicator appears after 500 ms. Canceling before this date will not show it.")}</div>
</Spin>
Your own indicator
Snippet locally and via ConfigProvider.spin.
<script lang="ts">
import { ConfigProvider, Spin, type SpinIndicatorInfo } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 32px;
}
</style>
{#snippet indicator(info: SpinIndicatorInfo)}
<svg
class={info.class}
style={info.style}
viewBox="0 0 32 32"
width="1em"
height="1em"
aria-hidden="true"
>
<circle
cx="16"
cy="16"
r="12"
fill="none"
stroke="currentColor"
stroke-width="3"
stroke-dasharray="48 28"
/>
</svg>
{/snippet}
<div class="examples">
<Spin {indicator} aria-label={("Own indicator")} />
<ConfigProvider spin={{ indicator }}>
<Spin aria-label={("Provider indicator")} />
</ConfigProvider>
</div>
Load percentage
Measurable percentage and conditional auto mode.
<script lang="ts">
import { Checkbox, InputNumber, Spin } from '@woodger/antd';
let percent = $state(35);
let auto = $state(false);
let spinning = $state(true);
</script>
<style>
.settings {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
margin-bottom: 24px;
}
.document {
min-height: 180px;
padding: 24px;
}
</style>
<div class="settings">
<InputNumber aria-label={("Spin Load Percentage")} value={percent} min={0} max={100}
onValueChange={next => { percent = next ?? 0; }} />
<Checkbox bind:checked={auto}>{("Automatic progress")}</Checkbox>
<Checkbox bind:checked={spinning}>{("Show progress")}</Checkbox>
</div>
<Spin
{spinning}
percent={auto ? 'auto' : percent}
description={("Processing files")}
aria-label={("File processing")}
>
<div class="document">{("Auto shows the conditional progress of expectations and does not measure real tasks.")}</div>
</Spin>
Semantic DOM
Styles object and function.
<script lang="ts">
import { ConfigProvider, Spin } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
gap: 24px;
}
.document {
min-height: 140px;
padding: 24px;
}
</style>
<ConfigProvider spin={{ styles: { description: 'font-weight: 600' } }}>
<div class="examples">
<Spin
description={("Styles object")}
aria-label={("Spin Object")}
classNames={{ root: 'spin-object' }}
styles={{
root: `
border: 1px dashed #d48806;
border-radius: 8px;
`,
indicator: 'color: #d48806'
}}
>
<div class="document">{("Document with frame.")}</div>
</Spin>
<Spin
description={("Styles function")}
aria-label={("Spin function")}
classNames={{ root: 'spin-function' }}
styles={({ props }) => ({ description: props.spinning ? 'font-weight: 700' : '' })}
>
<div class="document">{("Styles depend on props.")}</div>
</Spin>
</div>
</ConfigProvider>
Full screen wait
The example closes after two seconds.
<script lang="ts">
import { onDestroy } from 'svelte';
import { Button, Spin } from '@woodger/antd';
let spinning = $state(false);
let timer: ReturnType<typeof setTimeout> | undefined;
function show() {
clearTimeout(timer);
spinning = true;
timer = setTimeout(() => { spinning = false; }, 2000);
}
onDestroy(() => clearTimeout(timer));
</script>
<Button onclick={show}>{("Show full screen loading")}</Button>
<Spin
{spinning}
fullscreen
description={("Page loading · 2 seconds")}
aria-label={("Full screen loading")}
/>
Tokens and RTL
Sizes of points and height of loading area.
<script lang="ts">
import { ConfigProvider, Spin } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 32px;
margin-bottom: 24px;
}
.document {
min-height: 160px;
padding: 24px;
}
</style>
<ConfigProvider direction="rtl" theme={{
token: { colorPrimary: '#d48806' }, components: {
Spin: { dotSize: 28, dotSizeSM: 18, dotSizeLG: 40, contentHeight: 240 }
}
}}>
<div class="examples"><Spin size="small" aria-label={("Thematic Small Spin")} />
<Spin aria-label={("Thematic Spin")} /><Spin size="large" aria-label={("Thematic Big Spin")} /></div>
<Spin description={("Document preparation")} aria-label={("Issue Paper")}>
<div class="document">{("Nested topic and RTL direction.")}</div>
</Spin>
</ConfigProvider>
Changes in the card: 0. Data version: 0.
Profile update
Success, error, redo, cancel and save draft.
SpinExample.svelte<script lang="ts"> import { onDestroy, tick } from 'svelte'; import { Alert, Button, Checkbox, Input, Select, Spin, type SpinSize } from '@woodger/antd'; import { createSpinLoad } from './spin-load.model.svelte'; const model = createSpinLoad(); let delay = $state<0 | 200 | 500>(200); let size = $state<SpinSize>('medium'); let name = $state<string | undefined>(("Anna")); let notifications = $state(true); let edits = $state(0); let active = true; const sizes = ['small', 'medium', 'large'] .map((value) => ({ value: value as SpinSize, label: value })); let result = $derived( model.status === 'loading' ? "Profile is being updated..." : model.status === 'ready' ? `Data updated. Version: ${model.revision}.` : model.status === 'error' ? "Failed to load profile." : model.status === 'cancelled' ? "Loading cancelled." : "Edit draft and update data." ); async function cancel() { if (!model.cancel()) { return; } await tick(); if (active) { const startButton = document.getElementById('spin-example-start'); startButton?.focus({ preventScroll: true }); } } async function retryLoad() { if (!model.load()) { return; } await tick(); if (active && model.loading) { const card = document.getElementById('showcase-spin'); card?.focus({ preventScroll: true }); } } function reset() { model.reset(); name = ("Anna"); notifications = true; edits = 0; } onDestroy(() => { active = false; model.destroy(); }); </script> <style> .controls, .sizes { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; } .sizes { margin-block: 24px; gap: 32px; } .size { display: flex; flex-direction: column; align-items: center; gap: 8px; } .field { width: 160px; } .card { display: grid; gap: 16px; min-height: 190px; padding: 20px; border: 1px solid var(--ant-color-border-secondary); border-radius: var(--ant-border-radius-lg); } .card p { margin: 0; } .draft { max-width: 340px; } .loading { margin-block: 24px; } output { display: block; margin-top: 20px; color: var(--ant-color-text-secondary); } </style> {#snippet retry()} <Button onclick={() => { void retryLoad(); }}> {("Repeat profile loading")} </Button> {/snippet} <div class="controls"><Button id="spin-example-start" type="primary" loading={model.loading} onclick={() => model.load()} >{("Load profile")}</Button><Button disabled={model.loading} onclick={() => model.load('fast')} >{("Quick response")}</Button><Button disabled={model.loading} onclick={() => model.load('error')} >{("Profile loading error")}</Button><Button disabled={!model.loading} onclick={() => { void cancel(); }} >{("Cancel download")}</Button><Button onclick={reset} >{("Reset Spin example")}</Button><div class="field" ><Select aria-label={("Spin Delay")} bind:value={delay} options={([ { value: 0, label: "No delay" }, { value: 200, label: "200 ms" }, { value: 500, label: "500 ms" } ])} /></div><div class="field" ><Select aria-label={("Spin Size")} bind:value={size} options={(sizes)} /></div></div> <div class="sizes" aria-label={("Spin indicator dimensions")} >{#each sizes as item}<div class="size" ><Spin size={item.value} aria-hidden /><span>{(item.label)}</span></div>{/each}</div> <div class="loading"> <Spin spinning={model.loading} {delay} {size} description={("Loading profile...")} aria-label={("Member Profile")} id="showcase-spin" > <div class="card" ><label for="spin-example-name" >{("Name in draft")}</label><div class="draft" ><Input id="spin-example-name" bind:value={name} /></div><Checkbox bind:checked={notifications} > {("Profile notifications")} </Checkbox><p>{("Changes in the card: ")}{edits}{(". Data version: ")}{(model.revision)}.</p><div class="controls" ><Button onclick={() => { edits++; }} >{("Change card")}</Button><Button onclick={() => model.load()} >{("Update from card")}</Button></div></div> </Spin> </div> {#if model.status === 'error'}<Alert type="error" title={("Profile loading error")} description={("Draft saved. Try updating the data again.")} action={retry} showIcon />{/if} <output aria-label={("Result of Spin example")}>{result}</output>spin-load.model.svelte.tstype LoadStatus = 'idle' | 'loading' | 'ready' | 'error' | 'cancelled'; export type SpinLoadKind = 'normal' | 'fast' | 'error'; export function createSpinLoad() { let state = $state.raw<{ status: LoadStatus; revision: number }>({ status: 'idle', revision: 0 }); let timer: ReturnType<typeof setTimeout> | undefined; let generation = 0; let active = true; function clear() { generation++; clearTimeout(timer); timer = undefined; } return { get status() { return state.status; }, get loading() { return state.status === 'loading'; }, get revision() { return state.revision; }, load(kind: SpinLoadKind = 'normal') { if (!active || state.status === 'loading') { return false; } clear(); const current = generation; state = { ...state, status: 'loading' }; timer = setTimeout(() => { if (!active || current !== generation) { return; } timer = undefined; state = kind === 'error' ? { ...state, status: 'error' } : { status: 'ready', revision: state.revision + 1 }; }, kind === 'fast' ? 50 : 700); return true; }, cancel() { if (state.status !== 'loading') { return false; } clear(); state = { ...state, status: 'cancelled' }; return true; }, reset() { clear(); state = { status: 'idle', revision: 0 }; }, destroy() { active = false; clear(); } }; }
API
Nine themes of the official ant.design 6.7.0 page are mapped to the public Svelte API.
| Theme | Example or limitation |
|---|---|
| Basic Usage | A separate indicator with an accessible name. |
| Size | small, medium and large. |
| Embedded mode | Save a draft and lock the occupied area. |
| Customized description | Description via Svelte Snippet. |
| Delay | Delay appearance and cancellation. |
| Custom spinning indicator | Local indicator and ConfigProvider.spin. |
| Progress | Known percentage and explicitly enabled auto. |
| Custom semantic dom styling | Object and callback styles. |
| Fullscreen | Full screen waiting with automatic completion. |
Spin
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full local CSS prefix for Spin and its states; is also transmitted to indicator info. The empty string and undefined inherit ConfigProvider.prefixCls; default is ant-spin. | string | ConfigProvider + -spin |
spinning | Requested wait state. | boolean | true |
delay | Appearance delay in milliseconds. Content is blocked immediately. | number | 0 |
size | Indicator size. | small | medium | large | medium |
description | Text or Snippet description. | SpinContent | — |
indicator | Passive indicator; gets class/style, prefixCls and percent. | Snippet<[SpinIndicatorInfo]> | null | four points |
percent | Circular percentage or conditional waiting course. | number | auto | — |
fullscreen | Fixed layer in the current DOM branch. | boolean | false |
children | The contents of the nested mode are stored in the DOM. | SpinContent | — |
classNames | Named element classes, including root. | SpinSemanticSlots | callback | — |
styles | CSS lines; callback gets the current props. | SpinSemanticSlots | callback | — |
nativeElement | bind:nativeElement gets the root after mount. | HTMLDivElement | — |
ref | bind:ref with the nativeElement field. | SpinRef | — |
indicator - Snippet with SpinIndicatorInfo parameters; description/children accept text and Snippet. ConfigProvider.spin specifies common classes, styles and indicator.
Semantic DOM
A separate visible Spin reports status; the nested one has group, status descriptions and inert/aria-busy for container. The content is not unmounted. Mask is an additional slot for the full-screen layer.
| Slot | Purpose |
|---|---|
root | Root of single, nested or full screen mode. |
section | Indicator and description area. |
indicator | Standard or custom icon. |
description | Text below the indicator. |
container | Saved content with inert and aria-busy. |
Registration tokens
ConfigProvider.theme.components.Spin sets four tokens. colorPrimary controls the standard indicator; fullscreen uses a mask color and a base layer of the flyout elements.
| Token | Purpose |
|---|---|
contentHeight | Maximum height of the indicator area in nested mode. |
dotSize | Regular icon. |
dotSizeSM | Small icon. |
dotSizeLG | Large icon. |
| Token | Meaning |
|---|---|
colorPrimary | #2f54eb |
colorBgMask | rgba(0,0,0,0.45) |
colorBgContainer | #ffffff |
colorTextDescription | rgba(0,0,0,0.45) |
fontSize | 14 |
zIndexPopupBase | 1000 |
FAQ
Do fields disappear when waiting?
No. The nested DOM is preserved and becomes inert and aria-busy; the draft remains.
What does delay control?
Only the appearance of the indicator. The requested spinning blocks the content immediately.
Does auto measure actual load?
No. For actual volume, pass a number.
How to replace the indicator for an area?
Use ConfigProvider.spin. A static setter does not update already mounted instances.
fullscreen create a modal window?
No. This is a fixed layer without portal or focus trap.
What works without JavaScript?
The server displays standard indicators and content. Delays, auto and control work after hydration.