A ultra lightweight, dependency-free 3D rotating tag sphere for Vanilla JS, React, and Astro. View demo.
- Ultra lightweight core target.
- Zero runtime dependencies.
- Framework-ready entrypoints for Vanilla JS, React (18+), and Astro.
- SEO-friendly Astro pre-render strategy with client animation.
- Mouse and touch interaction support.
npm i tag-sphere
import { tagSphere } from 'tag-sphere'; const el = document.getElementById('my-sphere'); const instance = tagSphere(el, { tags: ['Astro', 'TypeScript', 'React'], radius: 120, speed: 0.01, direction: 20, });
import { TagSphere } from 'tag-sphere/react'; export function Example() { return ( <TagSphere tags={['Astro', 'TypeScript', 'React']} radius={120} speed={0.01} direction={20} style={{ width: 320, height: 320, position: 'relative' }} /> ); }
--- import TagSphere from 'tag-sphere/astro'; import 'tag-sphere/styles.css'; // Optional --- <TagSphere tags={['Astro', 'TypeScript', 'Vite']} radius={150} speed={0.01} direction={20} />
Unstyled(default): no CSS import from the library; bring your own styles via.ts-tagand/ortagClass.Styled (Default)(optional): importtag-sphere/styles.css(or aliastag-sphere/styles) for a basic preset.
| Property | Type | Default | Description |
|---|---|---|---|
tags |
string[] |
required | Labels to render. Min 1, max 50 (extra tags are truncated). |
radius |
number |
120 |
Sphere radius in pixels. Clamped to [60, 200]. |
speed |
number |
0.01 |
Idle angular speed. Normalized to absolute value, rounded to 3 decimals, clamped to [0.001, 0.08]. |
direction |
number |
20 |
Idle direction in clockwise degrees, normalized to [0, 359]. |
tagClass |
string |
undefined |
Extra class added to each .ts-tag. |
- Core library: Node
>=20. - Astro projects: follow your Astro version requirement.
npm install npm run build
The unified React showcase lives in examples/. To test library changes with hot-reloading alongside the React demo application, run the following from the repository root:
npm run examples:dev
MIT