08 · watch · loaders

Disco ball Pro

A free-floating chrome mirror ball spins under one cool light while something loads, throwing one cross flare at a time, and coasts to a stop when it is done.

Install

bash
npx shadcn@latest add @mu-pro/disco-ball

Pro. Installs with a licence key through the @mu-pro registry. Checkout opens soon: until then Pro installs are closed, and nothing can be bought on this site.

Usage

tsx
import { DiscoBall } from "@/components/mu/disco-ball/DiscoBall";

<DiscoBall />

How it works

Input and reduced motion

  • Pointer / touch: none; it is a status, not a control.
  • Keyboard: not focusable. Screen readers hear label, then doneLabel.
  • Off-screen or hidden tab: it stops drawing and keeps its place.
  • Arrive and leave: from a 4px blur over 200ms as the motor starts; on done it coasts, then fades.
  • Reduced motion: a still, lit ball; one slow glint breathes on its brightest mirror; on done it fades at once.
  • Performance: one canvas, one frame loop that runs only while the motor turns or the glint breathes; it stops when idle.

Place it

One scale for every loader (FOUNDATION, ### loaders). The box is exactly size and never shifts the layout.

// inline, in a sentence (xs: 1em of the text, 16px in body text). The root is a
// <span> and every part is phrasing content, so it is valid inside a <p>, a <label>
// or a <button>; at body leading (text-sm, text-base) the line keeps its height
<p className="text-sm">
  Syncing your library <DiscoBall size="xs" label="Syncing" done={!loading} />
</p>

// or as a status line of its own: the caption is the line's text and carries its baseline
<p className="text-sm text-muted-foreground">
  <DiscoBall size="xs" caption="Loading your set…" done={!loading} />
</p>

// in a button: the loader takes the icon's slot, so the button keeps its width;
// aria-disabled (not disabled) keeps a keyboard user's focus while it saves
<Button aria-disabled={saving} aria-busy={saving} onClick={() => !saving && save()}>
  {saving ? <DiscoBall size="sm" data-icon="inline-start" /> : <Save data-icon="inline-start" />}
  Save
</Button>

// centred in a card or empty state, with a caption (reserve the box: 104px with p-6;
// a 1px border adds 2px, so min-h-[106px] with one)
<div className="grid min-h-[104px] place-items-center p-6">
  <DiscoBall size="md" caption="Fetching 24 tracks" done={!loading} onExited={() => setShown(false)} />
</div>

// over a section: the content stays laid out underneath
<section className="relative" aria-busy={busy}>
  <div inert={busy}>{children}</div>
  {shown && (
    <div className="absolute inset-0 grid place-items-center bg-background/80">
      <DiscoBall size="lg" caption="Rendering" done={!busy} onExited={() => setShown(false)} />
    </div>
  )}
</section>

Props

PropDefaultWhat it does
size"md"xs · sm · md · lg · xl | the loader scale: 1em of the text, snapped to 4px (16 in body text) · 16 · 32 · 64 · 160px. Fewer, larger mirrors when small (6 rows up to 16px, 30 at 160), always one glint
donefalse— | true coasts the motor to a stop (1.2s), fades the ball (150ms) and calls onExited. false again spins it back up
accentfalse— | tints the light (and its flare and glow) with --mu-signal; the silver stays neutral
caption—text | visible: beside the ball at xs/sm (the line's own text), below it at md and up (muted). Screen readers hear it
label"Loading"— | what a screen reader hears when there is no caption (role="status", polite)
doneLabel"Loaded"— | what it hears once done
onExited—— | called when the exit has finished, so you can remove it
soundofftrue or 0–1 | the motor's spin-up when a person's press started it, and its spin-down on done after that; never a loop
className—— | added to the root

Licence

Included with Pro: use it in unlimited end products for you and your clients; no reselling as a kit. See the licence.