Dotted thought-orb loading indicators for AI & agent UIs. Nine hand-tuned animated states, each shipped at two purpose-tuned sizes, rendered on a plain 2D canvas — no WebGL, no filters, works identically in Chrome, Safari and Firefox.
Live demo · Repository · Report an issue
This repo already includes .github/workflows/pages.yml, which builds demo/ and deploys dist-demo to GitHub Pages on every push to main.
- In GitHub, open Settings → Pages.
- Set Source to GitHub Actions.
- Push to
main(or run Deploy demo to GitHub Pages manually from Actions).
npm install thinking-orbs<script setup lang="ts">
import { ThinkingOrb } from 'thinking-orbs';
</script>
<template>
<ThinkingOrb state="searching" :size="64" />
</template>Requires Vue 3.4+. That is the only peer — the package has no runtime dependencies of its own.
Nine verbs an agent can be doing, each a distinct animation:
<ThinkingOrb state="working" /> <!-- particles on tilted orbits -->
<ThinkingOrb state="searching" /> <!-- a scan meridian sweeps a dotted globe -->
<ThinkingOrb state="solving" /> <!-- bands scramble, then click back solved -->
<ThinkingOrb state="listening" /> <!-- a waveform rolls through the rings -->
<ThinkingOrb state="connecting" /> <!-- a constellation wires itself -->
<ThinkingOrb state="weaving" /> <!-- three strands plait around the sphere -->
<ThinkingOrb state="composing" /> <!-- an undulating multi-band sash -->
<ThinkingOrb state="breathing" /> <!-- a ring slowly morphing -->
<ThinkingOrb state="shaping" /> <!-- dotted outline: circle → triangle → square -->Two tuned presets — separate designs, not a scale factor. 64 for chat-avatar scale, 20 for inline-text scale. Each carries its own dot count, dot size and speed tuning:
<ThinkingOrb state="working" :size="64" />
<ThinkingOrb state="working" :size="20" />Any other number is accepted too. It's interpolated (or extrapolated beyond 20–64) between the two presets' dot count, dot size and speed — not a straight scale of the 64px design, since the presets themselves aren't:
<ThinkingOrb state="working" :size="40" />thinking-orbs/engine is the same geometry with no Vue and no DOM, for driving
your own renderer — an offscreen canvas in a worker, a server-side rasteriser, a
native canvas. Resolve a (state, size) pair once, then ask the mode for one
instant: what comes back is a finished, z-sorted list of circles (plus line
segments for connecting) with every value final.
import { MODE_FRAMES, resolvePreset } from 'thinking-orbs/engine';
const { mode, speed, opts } = resolvePreset('searching', 64);
const { dots, lines } = MODE_FRAMES[mode](64, elapsedSeconds * speed, opts);white is the paper-theme ink value in [0,1]; on a dark substrate a renderer
mirrors it (1 - white) so near dots read bright.
Strictly monochrome — light ink for dark backgrounds, dark ink for light backgrounds — with the mode picked automatically from the host project:
<ThinkingOrb theme="auto" /> <!-- default — detects from the project -->
<ThinkingOrb theme="dark" /> <!-- pin: light dots for dark backgrounds -->
<ThinkingOrb theme="light" /> <!-- pin: dark dots for light backgrounds -->auto resolves in three layers and updates live when any of them change:
- an ancestor
data-theme="dark|light"attribute ordark/lightclass (the Tailwind / shadcn convention), watched viaMutationObserver; - otherwise
prefers-color-scheme, subscribed for live OS theme switches; - SSR-safe — the canvas paints only on the client, after the theme has resolved.
<ThinkingOrb
state="solving"
:size="20"
:speed="1.5"
:paused="false"
aria-label="Analysing repository…"
/>
<!-- speed: multiplier on the preset's baked speed -->
<!-- paused: freeze on the current frame -->
<!-- aria-label: overrides the per-state default -->All other <canvas> attributes (class, style, data-*, …) pass through via Vue's fallthrough attributes.
role="img"with a sensible per-statearia-labelout of the box.prefers-reduced-motion: reducerenders a static representative frame — no animation — and still follows the live theme.- Every instance pauses automatically when scrolled offscreen (
IntersectionObserver) or when the tab is hidden, and resumes in phase — all instances share one clock. - Plain 2D canvas arcs only: no
ctx.filter, no SVG filters, no WebGL — the same pixels everywhere, cheap on low-end devices. Device-pixel-ratio capped at 2.
MIT © Jakub Antalik