Loaders JS behaviour

Orbit dots

Four dots racing round an elliptical orbit, their soft stagger reading as a comet tail; inside a save button that really works for two seconds and then ticks — and in a sync chip that halts dead in red when the server won’t answer, until the retry runs.

Documentation

Real scenarios

The component as it is used in a product — not a specimen grid.

A button that shows its work

Four dots chase each other round an elliptical orbit — the stagger reads as a comet tail. Press save: the dots really work for two seconds, then a tick draws itself in and the button settles green.

Atlas Design · workspace settings

Frankfurt region · team plan

Workspace name Atlas Design
Host region Frankfurt · eu-central-1
Plan Team · 12 seats

When the server goes quiet

The same orbit, shrunk into a sync chip. The first attempt here fails with a 504 — the dots stop dead and the chip reads the error out loud; Retry walks the same path and goes green.

Vector Calendar · sync

Server did not answer (504). Check the connection and try again.

Important props

Important props
Prop Type Default What it does
dots count '4' Three to five dots; the stragglers shrink and fade so the eye reads a tail.
duration s '1.15' Seconds per lap; the cubic-bezier bunches and releases the dots through the ellipse’s bends — the elastic chase itself.
orbit px '22 × 14' The ellipse drawn with offset-path; the 22×14 ratio keeps the lap wide and calm.
work ms '2000' How long the button really works before the tick — exactly the wait your user sits through, not a frame more.
error state '504' On error the dots halt and turn red; Retry walks the very same path again.

Snippet

<button type="button" class="ldo-save" data-state="working">
<span class="ldo-orbit" aria-hidden="true"><i></i><i></i><i></i><i></i></span>
<span>Saving…</span>
</button>

<style>
.ldo-save { display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
min-inline-size: 11rem; block-size: 2.8rem; padding-inline: 1.3rem; border: none;
border-radius: 999px; background: #4f46e5; color: #fff;
font: 600 .88rem/1 'Inter', 'Vazirmatn', sans-serif; cursor: pointer; }
.ldo-save[data-state='done'] { background: #059669; }
.ldo-orbit { position: relative; inline-size: 22px; block-size: 14px; flex: none; }
.ldo-orbit i { position: absolute; inset: 0;
offset-path: path('M2 7 A9 5.5 0 1 1 20 7 A9 5.5 0 1 1 2 7');
animation: ldo-lap 1.15s cubic-bezier(.62,.05,.37,.95) infinite; }
.ldo-orbit i::after { content: ''; position: absolute; inset-block-start: 50%; inset-inline-start: 50%;
inline-size: 5px; aspect-ratio: 1; border-radius: 50%; background: currentColor;
translate: -50% -50%; }
.ldo-orbit i:nth-child(2) { animation-delay: -.16s; } .ldo-orbit i:nth-child(2)::after { opacity: .7; scale: .8; }
.ldo-orbit i:nth-child(3) { animation-delay: -.32s; } .ldo-orbit i:nth-child(3)::after { opacity: .5; scale: .6; }
.ldo-orbit i:nth-child(4) { animation-delay: -.48s; } .ldo-orbit i:nth-child(4)::after { opacity: .35; scale: .45; }
@keyframes ldo-lap { from { offset-distance: 0%; } to { offset-distance: 100%; } }
</style>
// app/Pages/WorkspaceSettings.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 SaveButton from '@/components/SaveButton';

export default function WorkspaceSettings() {
  return (
    <NabuXUIProvider locale="en" linkComponent={Link}>
      <main className="nx-page">
        <SaveButton workMs={2000} />
      </main>
    </NabuXUIProvider>
  );
}
// SaveButton.jsx — orbit dots chasing inside a button that really saves
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';

export default function SaveButton({ workMs = 2000 }) {
  const [state, setState] = useState('idle'); // idle | working | done
  const timers = useRef<number[]>([]);

  // Every timeout is tracked so unmounting never ticks a dead button.
  useEffect(() => () => timers.current.forEach(clearTimeout), []);

  const later = (fn: () => void, ms: number) => {
    timers.current.push(window.setTimeout(fn, ms));
  };

  const save = () => {
    if (state === 'working') return;
    setState('working');
    later(() => {
      setState('done');
      later(() => setState('idle'), 1800);
    }, workMs);
  };

  const label = { idle: 'Save changes', working: 'Saving…', done: 'Saved' }[state];

  return (
    <>
      <style>{`
        .ldo-save { display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
                    min-inline-size: 11rem; block-size: 2.8rem; padding-inline: 1.3rem; border: none;
                    border-radius: 999px; background: #4f46e5; color: #fff; cursor: pointer;
                    font: 600 .88rem/1 'Inter', sans-serif; transition: background-color .25s ease; }
        .ldo-save:hover:not(:disabled) { background: #4338ca; }
        .ldo-save[data-state='done'] { background: #059669; }
        .ldo-save:disabled { cursor: default; }
        .ldo-orbit { position: relative; inline-size: 22px; block-size: 14px; flex: none; }
        .ldo-orbit i { position: absolute; inset: 0;
                       offset-path: path('M2 7 A9 5.5 0 1 1 20 7 A9 5.5 0 1 1 2 7');
                       animation: ldo-lap 1.15s cubic-bezier(.62,.05,.37,.95) infinite; }
        .ldo-orbit i::after { content: ''; position: absolute; inset-block-start: 50%; inset-inline-start: 50%;
                              inline-size: 5px; aspect-ratio: 1; border-radius: 50%; background: currentColor;
                              translate: -50% -50%; }
        .ldo-orbit i:nth-child(2) { animation-delay: -.16s; } .ldo-orbit i:nth-child(2)::after { opacity: .7; scale: .8; }
        .ldo-orbit i:nth-child(3) { animation-delay: -.32s; } .ldo-orbit i:nth-child(3)::after { opacity: .5; scale: .6; }
        .ldo-orbit i:nth-child(4) { animation-delay: -.48s; } .ldo-orbit i:nth-child(4)::after { opacity: .35; scale: .45; }
        .ldo-check { inline-size: 1.15rem; flex: none; }
        .ldo-check path { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
                          stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24;
                          animation: ldo-draw .45s ease-out forwards; }
        @keyframes ldo-lap { from { offset-distance: 0%; } to { offset-distance: 100%; } }
        @keyframes ldo-draw { to { stroke-dashoffset: 0; } }
        @media (prefers-reduced-motion: reduce) {
          .ldo-orbit i { animation: none; }
          .ldo-orbit i:nth-child(1) { offset-distance: 0%; }  .ldo-orbit i:nth-child(2) { offset-distance: 25%; }
          .ldo-orbit i:nth-child(3) { offset-distance: 50%; } .ldo-orbit i:nth-child(4) { offset-distance: 75%; }
          .ldo-check path { animation: none; stroke-dashoffset: 0; }
        }
      `}</style>
      <button type="button" className="ldo-save" data-state={state}
              onClick={save} disabled={state === 'working'}>
        {state === 'working' && (
          <span className="ldo-orbit" aria-hidden="true"><i /><i /><i /><i /></span>
        )}
        {state === 'done' && (
          <svg className="ldo-check" viewBox="0 0 24 24" aria-hidden="true">
            <path d="M4.5 12.5l5 5 10-11" />
          </svg>
        )}
        <span aria-live="polite">{label}</span>
      </button>
    </>
  );
}
<!-- SaveButton.vue — orbit dots chasing inside a button that really saves -->
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue';
import '@nabuxai/ui-core/css';

const props = defineProps<{ workMs?: number }>();
const state = ref<'idle' | 'working' | 'done'>('idle');
const timers: number[] = [];

const later = (fn: () => void, ms: number) => { timers.push(window.setTimeout(fn, ms)); };

const save = () => {
  if (state.value === 'working') return;
  state.value = 'working';
  later(() => {
    state.value = 'done';
    later(() => { state.value = 'idle'; }, 1800);
  }, props.workMs ?? 2000);
};

// Unmounting clears every pending tick — the button never lies.
onBeforeUnmount(() => timers.forEach(clearTimeout));
</script>

<template>
  <button type="button" class="ldo-save" :data-state="state" :disabled="state === 'working'" @click="save">
    <span v-if="state === 'working'" class="ldo-orbit" aria-hidden="true"><i /><i /><i /><i /></span>
    <svg v-if="state === 'done'" class="ldo-check" viewBox="0 0 24 24" aria-hidden="true">
      <path d="M4.5 12.5l5 5 10-11" />
    </svg>
    <span aria-live="polite">
      {{ state === 'working' ? 'Saving…' : state === 'done' ? 'Saved' : 'Save changes' }}
    </span>
  </button>
</template>

<style scoped>
.ldo-save { display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
            min-inline-size: 11rem; block-size: 2.8rem; padding-inline: 1.3rem; border: none;
            border-radius: 999px; background: #4f46e5; color: #fff; cursor: pointer;
            font: 600 .88rem/1 'Inter', sans-serif; transition: background-color .25s ease; }
.ldo-save:hover:not(:disabled) { background: #4338ca; }
.ldo-save[data-state='done'] { background: #059669; }
.ldo-save:disabled { cursor: default; }
.ldo-orbit { position: relative; inline-size: 22px; block-size: 14px; flex: none; }
.ldo-orbit i { position: absolute; inset: 0;
               offset-path: path('M2 7 A9 5.5 0 1 1 20 7 A9 5.5 0 1 1 2 7');
               animation: ldo-lap 1.15s cubic-bezier(.62,.05,.37,.95) infinite; }
.ldo-orbit i::after { content: ''; position: absolute; inset-block-start: 50%; inset-inline-start: 50%;
                      inline-size: 5px; aspect-ratio: 1; border-radius: 50%; background: currentColor;
                      translate: -50% -50%; }
.ldo-orbit i:nth-child(2) { animation-delay: -.16s; } .ldo-orbit i:nth-child(2)::after { opacity: .7; scale: .8; }
.ldo-orbit i:nth-child(3) { animation-delay: -.32s; } .ldo-orbit i:nth-child(3)::after { opacity: .5; scale: .6; }
.ldo-orbit i:nth-child(4) { animation-delay: -.48s; } .ldo-orbit i:nth-child(4)::after { opacity: .35; scale: .45; }
.ldo-check { inline-size: 1.15rem; flex: none; }
.ldo-check path { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
                  stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24;
                  animation: ldo-draw .45s ease-out forwards; }
@keyframes ldo-lap { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@keyframes ldo-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .ldo-orbit i { animation: none; }
  .ldo-orbit i:nth-child(1) { offset-distance: 0%; }  .ldo-orbit i:nth-child(2) { offset-distance: 25%; }
  .ldo-orbit i:nth-child(3) { offset-distance: 50%; } .ldo-orbit i:nth-child(4) { offset-distance: 75%; }
  .ldo-check path { animation: none; stroke-dashoffset: 0; }
}
</style>
<!-- SaveButton.svelte — orbit dots chasing inside a button that really saves -->
<script lang="ts">
  import { onDestroy } from 'svelte';
  import '@nabuxai/ui-core/css';

  let { workMs = 2000 } = $props();
  let state = $state<'idle' | 'working' | 'done'>('idle');
  const timers: number[] = [];

  const later = (fn: () => void, ms: number) => { timers.push(window.setTimeout(fn, ms)); };

  const save = () => {
    if (state === 'working') return;
    state = 'working';
    later(() => {
      state = 'done';
      later(() => { state = 'idle'; }, 1800);
    }, workMs);
  };

  // Unmounting clears every pending tick — the button never lies.
  onDestroy(() => timers.forEach(clearTimeout));
</script>

<button type="button" class="ldo-save" data-state={state} disabled={state === 'working'} onclick={save}>
  {#if state === 'working'}
    <span class="ldo-orbit" aria-hidden="true"><i /><i /><i /><i /></span>
  {/if}
  {#if state === 'done'}
    <svg class="ldo-check" viewBox="0 0 24 24" aria-hidden="true"><path d="M4.5 12.5l5 5 10-11" /></svg>
  {/if}
  <span aria-live="polite">
    {state === 'working' ? 'Saving…' : state === 'done' ? 'Saved' : 'Save changes'}
  </span>
</button>

<style>
  .ldo-save { display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
              min-inline-size: 11rem; block-size: 2.8rem; padding-inline: 1.3rem; border: none;
              border-radius: 999px; background: #4f46e5; color: #fff; cursor: pointer;
              font: 600 .88rem/1 'Inter', sans-serif; transition: background-color .25s ease; }
  .ldo-save:hover:not(:disabled) { background: #4338ca; }
  .ldo-save[data-state='done'] { background: #059669; }
  .ldo-save:disabled { cursor: default; }
  .ldo-orbit { position: relative; inline-size: 22px; block-size: 14px; flex: none; }
  .ldo-orbit i { position: absolute; inset: 0;
                 offset-path: path('M2 7 A9 5.5 0 1 1 20 7 A9 5.5 0 1 1 2 7');
                 animation: ldo-lap 1.15s cubic-bezier(.62,.05,.37,.95) infinite; }
  .ldo-orbit i::after { content: ''; position: absolute; inset-block-start: 50%; inset-inline-start: 50%;
                        inline-size: 5px; aspect-ratio: 1; border-radius: 50%; background: currentColor;
                        translate: -50% -50%; }
  .ldo-orbit i:nth-child(2) { animation-delay: -.16s; } .ldo-orbit i:nth-child(2)::after { opacity: .7; scale: .8; }
  .ldo-orbit i:nth-child(3) { animation-delay: -.32s; } .ldo-orbit i:nth-child(3)::after { opacity: .5; scale: .6; }
  .ldo-orbit i:nth-child(4) { animation-delay: -.48s; } .ldo-orbit i:nth-child(4)::after { opacity: .35; scale: .45; }
  .ldo-check { inline-size: 1.15rem; flex: none; }
  .ldo-check path { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
                    stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24;
                    animation: ldo-draw .45s ease-out forwards; }
  @keyframes ldo-lap { from { offset-distance: 0%; } to { offset-distance: 100%; } }
  @keyframes ldo-draw { to { stroke-dashoffset: 0; } }
  @media (prefers-reduced-motion: reduce) {
    .ldo-orbit i { animation: none; }
    .ldo-orbit i:nth-child(1) { offset-distance: 0%; }  .ldo-orbit i:nth-child(2) { offset-distance: 25%; }
    .ldo-orbit i:nth-child(3) { offset-distance: 50%; } .ldo-orbit i:nth-child(4) { offset-distance: 75%; }
    .ldo-check path { animation: none; stroke-dashoffset: 0; }
  }
</style>