Loaders
JS behaviour
Segmented spin
The iOS-style stepped spin: eight arcs fading in sequence, holding the eye in orbit — no percent, no promises, featherweight. Three real status cards at three sizes: a contacts sync, a video upload that completes, and a flight search whose server goes quiet until the retry turns green.
Real scenarios
The component as it is used in a product — not a specimen grid.
One spinner, three jobs, three sizes
Eight arcs fade in sequence — the eye reads a turn, the browser spends almost nothing. Small in a list-row sync, medium on an upload, large on a full search; the slot keeps its size as working becomes a tick or an alert.
Upload · q4-cut.mp4
Flights · Singapore – Frankfurt
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| segments | count | '8' | Eight arcs on pathLength=100; each arc shows 10.5 units and gaps over the rest. |
| fade | s | '0.96' | The fade cycle; each arc carries a −120ms stepped delay so the chase reads both ticked and smooth. |
| sizes | px | '18 · 26 · 38' | One family, three sizes; small for list rows, large for full-page waits. |
| states | attr | 'working · done · error' | On success the arcs yield to a tick, on error to an alert — the indicator slot keeps one size. |
| weight | stroke | '2.4' | The arc weight in viewBox units; it scales as the indicator grows, no redraw needed. |
Snippet
<span class="lds-spin" style="--lds-size: 26px" role="status" aria-label="Syncing">
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="8.5" pathLength="100" transform="rotate(0 12 12)" style="--lds-i: 0"/>
<circle cx="12" cy="12" r="8.5" pathLength="100" transform="rotate(45 12 12)" style="--lds-i: 1"/>
<circle cx="12" cy="12" r="8.5" pathLength="100" transform="rotate(90 12 12)" style="--lds-i: 2"/>
<circle cx="12" cy="12" r="8.5" pathLength="100" transform="rotate(135 12 12)" style="--lds-i: 3"/>
</svg>
</span>
<style>
.lds-spin { display: inline-grid; place-items: center; inline-size: var(--lds-size); block-size: var(--lds-size);
color: #0a84ff; }
.lds-spin svg { inline-size: 100%; block-size: 100%; }
.lds-spin circle {
fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
stroke-dasharray: 10.5 89.5; stroke-dashoffset: -6;
animation: lds-fade .96s linear infinite;
animation-delay: calc(var(--lds-i) * -.12s);
}
@keyframes lds-fade { 0%, 100% { opacity: .12; } 42% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lds-spin circle { animation: none; opacity: .85; } }
</style>
// app/Pages/Sync.jsx — Inertia (React) page; renders the React snippet
// below unchanged, with Inertia's Link in the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import ContactsSync from '@/components/ContactsSync';
export default function Sync() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<ContactsSync total={512} startFrom={384} />
</main>
</NabuXUIProvider>
);
}
// ContactsSync.jsx — the segmented spin counting a real sync
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';
export default function ContactsSync({ total = 512, startFrom = 384 }) {
const [state, setState] = useState('working'); // working | done
const [count, setCount] = useState(startFrom);
const ticks = useRef<number[]>([]);
// Unmount clears every interval — no spinner spins behind the page.
useEffect(() => () => ticks.current.forEach(clearInterval), []);
useEffect(() => {
const t = window.setInterval(() => {
setCount((c) => {
const next = Math.min(total, c + 3 + Math.floor(Math.random() * 4));
if (next >= total) { clearInterval(t); setState('done'); }
return next;
});
}, 240);
ticks.current.push(t);
}, []);
const replay = () => {
if (state === 'working') return;
setState('working');
setCount(0);
const t = window.setInterval(() => {
setCount((c) => {
const next = Math.min(total, c + 6 + Math.floor(Math.random() * 9));
if (next >= total) { clearInterval(t); setState('done'); }
return next;
});
}, 110);
ticks.current.push(t);
};
return (
<>
<style>{`
.lds-card { display: grid; gap: .8rem; justify-items: start; padding: 1.2rem;
border: 1px solid #e7e5e4; border-radius: 1rem;
font-family: 'Inter', sans-serif; max-inline-size: 20rem; }
.lds-head { display: flex; align-items: center; gap: .8rem; }
.lds-spin { display: inline-grid; place-items: center; flex: none;
inline-size: var(--lds-size); block-size: var(--lds-size); color: #0a84ff; }
.lds-spin svg { inline-size: 100%; block-size: 100%; }
.lds-spin circle { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
stroke-dasharray: 10.5 89.5; stroke-dashoffset: -6;
animation: lds-fade .96s linear infinite;
animation-delay: calc(var(--lds-i) * -.12s); }
@keyframes lds-fade { 0%, 100% { opacity: .12; } 42% { opacity: 1; } }
.lds-card[data-state='done'] .lds-spin { color: #059669; }
.lds-card h4 { margin: 0; font-size: .9rem; }
.lds-meta { margin: 0; font-size: .78rem; color: #78716c; }
.lds-replay { margin-block-start: .2rem; border: none; background: none; color: #0a84ff;
font: 600 .78rem/1 inherit; cursor: pointer; text-decoration: underline;
text-underline-offset: .2em; }
@media (prefers-reduced-motion: reduce) { .lds-spin circle { animation: none; opacity: .85; } }
`}</style>
<div className="lds-card" data-state={state}>
<div className="lds-head">
<span className="lds-spin" style={{ ['--lds-size' as string]: '26px' }} role="status" aria-label="Syncing">
{state === 'working' ? (
<svg viewBox="0 0 24 24" aria-hidden="true">
{Array.from({ length: 8 }, (_, i) => (
<circle key={i} cx="12" cy="12" r="8.5" pathLength="100"
transform={`rotate(${i * 45} 12 12)`} style={{ ['--lds-i' as string]: i }} />
))}
</svg>
) : (
<svg viewBox="0 0 24 24" aria-hidden="true">
<path fill="none" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round"
strokeLinejoin="round" d="M4.5 12.5l5 5 10-11" />
</svg>
)}
</span>
<h4>Contacts · Outlook sync</h4>
</div>
<p className="lds-meta" aria-live="polite">
{state === 'done' ? `Complete · ${total} contacts` : `${count} of ${total} contacts…`}
</p>
{state === 'done' && (
<button type="button" className="lds-replay" onClick={replay}>Run it again</button>
)}
</div>
</>
);
}
<!-- ContactsSync.vue — the segmented spin counting a real sync -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
const props = defineProps<{ total?: number; startFrom?: number }>();
const state = ref<'working' | 'done'>('working');
const count = ref(props.startFrom ?? 384);
const ticks: number[] = [];
const watch = (step: () => number, ms: number) => {
const t = window.setInterval(() => {
count.value = Math.min(props.total ?? 512, step());
if (count.value >= (props.total ?? 512)) { clearInterval(t); state.value = 'done'; }
}, ms);
ticks.push(t);
};
onMounted(() => watch(() => count.value + 3 + Math.floor(Math.random() * 4), 240));
const replay = () => {
if (state.value === 'working') return;
state.value = 'working';
count.value = 0;
watch(() => count.value + 6 + Math.floor(Math.random() * 9), 110);
};
// Unmount clears every interval — no spinner spins behind the page.
onBeforeUnmount(() => ticks.forEach(clearInterval));
</script>
<template>
<div class="lds-card" :data-state="state">
<div class="lds-head">
<span class="lds-spin" style="--lds-size: 26px" role="status" aria-label="Syncing">
<svg v-if="state === 'working'" viewBox="0 0 24 24" aria-hidden="true">
<circle v-for="i in 8" :key="i" cx="12" cy="12" r="8.5" pathLength="100"
:transform="`rotate(${(i - 1) * 45} 12 12)`" :style="{ '--lds-i': i - 1 }" />
</svg>
<svg v-else viewBox="0 0 24 24" aria-hidden="true">
<path fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"
stroke-linejoin="round" d="M4.5 12.5l5 5 10-11" />
</svg>
</span>
<h4>Contacts · Outlook sync</h4>
</div>
<p class="lds-meta" aria-live="polite">
{{ state === 'done' ? `Complete · ${total ?? 512} contacts` : `${count} of ${total ?? 512} contacts…` }}
</p>
<button v-if="state === 'done'" type="button" class="lds-replay" @click="replay">Run it again</button>
</div>
</template>
<style scoped>
.lds-card { display: grid; gap: .8rem; justify-items: start; padding: 1.2rem;
border: 1px solid #e7e5e4; border-radius: 1rem;
font-family: 'Inter', sans-serif; max-inline-size: 20rem; }
.lds-head { display: flex; align-items: center; gap: .8rem; }
.lds-spin { display: inline-grid; place-items: center; flex: none;
inline-size: var(--lds-size); block-size: var(--lds-size); color: #0a84ff; }
.lds-spin svg { inline-size: 100%; block-size: 100%; }
.lds-spin circle { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
stroke-dasharray: 10.5 89.5; stroke-dashoffset: -6;
animation: lds-fade .96s linear infinite;
animation-delay: calc(var(--lds-i) * -.12s); }
@keyframes lds-fade { 0%, 100% { opacity: .12; } 42% { opacity: 1; } }
.lds-card[data-state='done'] .lds-spin { color: #059669; }
.lds-card h4 { margin: 0; font-size: .9rem; }
.lds-meta { margin: 0; font-size: .78rem; color: #78716c; }
.lds-replay { margin-block-start: .2rem; border: none; background: none; color: #0a84ff;
font: 600 .78rem/1 inherit; cursor: pointer; text-decoration: underline;
text-underline-offset: .2em; }
@media (prefers-reduced-motion: reduce) { .lds-spin circle { animation: none; opacity: .85; } }
</style>
<!-- ContactsSync.svelte — the segmented spin counting a real sync -->
<script lang="ts">
import { onDestroy, onMount } from 'svelte';
import '@nabuxai/ui-core/css';
let { total = 512, startFrom = 384 } = $props();
let state = $state<'working' | 'done'>('working');
let count = $state(startFrom);
const ticks: number[] = [];
const watch = (step: () => number, ms: number) => {
const t = window.setInterval(() => {
count = Math.min(total, step());
if (count >= total) { clearInterval(t); state = 'done'; }
}, ms);
ticks.push(t);
};
onMount(() => watch(() => count + 3 + Math.floor(Math.random() * 4), 240));
const replay = () => {
if (state === 'working') return;
state = 'working';
count = 0;
watch(() => count + 6 + Math.floor(Math.random() * 9), 110);
};
// Unmount clears every interval — no spinner spins behind the page.
onDestroy(() => ticks.forEach(clearInterval));
</script>
<div class="lds-card" data-state={state}>
<div class="lds-head">
<span class="lds-spin" style="--lds-size: 26px" role="status" aria-label="Syncing">
{#if state === 'working'}
<svg viewBox="0 0 24 24" aria-hidden="true">
{#each Array(8) as _, i}
<circle cx="12" cy="12" r="8.5" pathLength="100"
transform={`rotate(${i * 45} 12 12)`} style={`--lds-i: ${i}`} />
{/each}
</svg>
{:else}
<svg viewBox="0 0 24 24" aria-hidden="true">
<path fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"
stroke-linejoin="round" d="M4.5 12.5l5 5 10-11" />
</svg>
{/if}
</span>
<h4>Contacts · Outlook sync</h4>
</div>
<p class="lds-meta" aria-live="polite">
{state === 'done' ? `Complete · ${total} contacts` : `${count} of ${total} contacts…`}
</p>
{#if state === 'done'}
<button type="button" class="lds-replay" onclick={replay}>Run it again</button>
{/if}
</div>
<style>
.lds-card { display: grid; gap: .8rem; justify-items: start; padding: 1.2rem;
border: 1px solid #e7e5e4; border-radius: 1rem;
font-family: 'Inter', sans-serif; max-inline-size: 20rem; }
.lds-head { display: flex; align-items: center; gap: .8rem; }
.lds-spin { display: inline-grid; place-items: center; flex: none;
inline-size: var(--lds-size); block-size: var(--lds-size); color: #0a84ff; }
.lds-spin svg { inline-size: 100%; block-size: 100%; }
.lds-spin circle { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
stroke-dasharray: 10.5 89.5; stroke-dashoffset: -6;
animation: lds-fade .96s linear infinite;
animation-delay: calc(var(--lds-i) * -.12s); }
@keyframes lds-fade { 0%, 100% { opacity: .12; } 42% { opacity: 1; } }
.lds-card[data-state='done'] .lds-spin { color: #059669; }
.lds-card h4 { margin: 0; font-size: .9rem; }
.lds-meta { margin: 0; font-size: .78rem; color: #78716c; }
.lds-replay { margin-block-start: .2rem; border: none; background: none; color: #0a84ff;
font: 600 .78rem/1 inherit; cursor: pointer; text-decoration: underline;
text-underline-offset: .2em; }
@media (prefers-reduced-motion: reduce) { .lds-spin circle { animation: none; opacity: .85; } }
</style>