Spinner
Terminal-inspired TUI spinner with four animation styles. The default snake variant renders a 3×3 pixel grid with a trailing dot that moves clockwise — like a pixelated snake.
Installation
dgadd ships in @diffgazer/add on npm: pnpm add -D @diffgazer/add puts it on pnpm exec, and npx @diffgazer/add runs it without the install.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS from the installed package.
Usage
Examples
Variants
Sizes
Label Positions
Gap and Speed
API Reference
Spinner
CSS variables
Accessibility
Notes
Labels
Pass children to Spinner to render a label. The labelPosition prop controls where the label appears relative to the glyph: right (default), left, top, or bottom.
Gap Control
The gap prop controls the space between the spinner glyph and its label. Values: "none" (0), "sm" (4px), "md" (8px, default), "lg" (12px). Works for both horizontal and vertical label positions.
Fixed Glyph Box
All four variants animate inside one 2em-square box that scales with the size prop, so swapping variant or cycling frames never moves the label or reflows the row. 2em is the largest footprint any variant needs — the lg snake grid measures 32px at its 16px font size, and the widest dots frame reserves 3ch.
Snake Variant
A 3×3 grid of dots with a 3-dot trail moving clockwise around the 8-position perimeter. The head, body, tail, and idle alphas come from the --spinner-trail-* variables in spinner.css; the light palette raises the ramp (idle 32% instead of 15%) so the trail stays legible on a light background.
Reduced Motion
When prefers-reduced-motion is active, the animation stops at the first frame. If the preference changes at runtime, the animation responds accordingly.
Speed Override
The speed prop overrides the default frame interval in milliseconds. Default speeds: snake 100ms, braille 80ms, dots 300ms, pulse 80ms.
Source
Install via CLI: pnpm exec dgadd add ui/spinner.
Highlighted source loads after this disclosure opens. Browse the source repository.