Cómo funciona
A 2D canvas 2.4 times the orb's size is centred on its place in the layout. Points are spread over a sphere on a golden-angle spiral; each frame turns the sphere round its vertical axis (0.55 rad/s), leans it toward the viewer and draws every point as a short round-capped stroke whose width and opacity follow its depth, over a radial core. A burst pushes each point outward by its own amount (about one in six kicks far) along a curve that rises in 130ms and springs back with a damped wave; the stroke runs from where the point was a few milliseconds earlier, so fast points leave streaks. On done the points move along an eased path to evenly spaced slots on a ring, each taking the slot nearest its angle so none cross, while the rest fade into them; then the loop stops. Colours are read from the stylesheet once per burst (accent on light surfaces; a lighter accent with additive blending in the dark theme), and the loop also pauses out of view and in hidden tabs.
Úsalo para
- An assistant composing an answer, a calculation, a plan being built.
- Long work where a plain spinner feels mechanical: an import, a render, a search over many records.
- A status line that should end in a clear, calm done state.
Busca otra opción cuando
- Inside buttons and dense rows: use a small spinner.
- Measurable progress: use a progress bar or ring with a percentage.
- Many at once on one screen: several canvases would compete for attention.
Uso
import { ParticleOrb } from './ParticleOrb.jsx'
export function AnswerStatus({ pending }) {
return (
<ParticleOrb
status={pending ? 'working' : 'done'}
labels={{ status: { working: 'Calculating…', done: 'Done' } }}
/>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
status | 'working' | 'idle' | 'done' | 'working' | Working turns the sphere and fires bursts; idle keeps it turning quietly; done settles it into a dotted ring and draws a check. Changing back from done unfolds the sphere again. |
size | number | 40 | Diameter of the orb's place in the layout, in px. Bursts draw into a canvas 2.4 times that size without taking extra space. |
particles | number | 220 | Number of particles, 40–600. |
burstEvery | number | 1400 | Milliseconds between bursts while working. |
label | ReactNode | — | Text beside the orb. Defaults to labels.status[status]. |
showLabel | boolean | true | Shows the text beside the orb. It is still announced when hidden. |
labels | { status: { working, idle, done } } | — | Replaces the built-in status text. |
...rest | HTMLAttributes<HTMLDivElement> | — | Other attributes go to the root <div>. |
Accesibilidad
- The status text is announced through a polite live region (role="status"); the canvas is decorative and hidden from screen readers.
- Done is not shown by motion alone: the text changes and a check is drawn.
- The sheen on the working text moves between the secondary and the primary text colour, so it never loses contrast.
- Reduced motion draws a still dotted ring (fainter while working, solid when done), stops the sheen and shows the check at once.
Movimiento
Turn: 0.55 rad/s with a 3% breath. Burst: every 1.4s, a 130ms push and a spring back over about a second. Settle into the ring: 820ms ease-in-out; the check draws in 360ms after 560ms. Text sheen: 2.1s loop.
Añádelo a tu proyecto
Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.
ParticleOrb.jsxparticle-orb.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.





