Sparkles Text
Text with twinkling star sparkles that scale and rotate, with a static accent under reduced motion.
pnpm dlx @glinui/cli@latest add sparkles-textGlin UI Pro
Lifetime access to every template.
Installation
pnpm dlx @glinui/cli@latest add sparkles-textCredits. Adapted from Magic UI (MIT, (c) Magic UI). No motion dependency (Web Animations), sparkles generated after mount for SSR safety, token colors and reduced motion levels. Attribution details.
Prefer the package?
Usage
Improvements: no motion dependency (Web Animations API), sparkles are created after mount so there is no hydration mismatch from Math.random, a fixed pool re-rolls position in place instead of replacing DOM every 100ms, positions use logical inline-start so RTL mirrors, and the count is capped.
Engines: the `engine` prop is not applicable. Continuous particle twinkle in css keyframes; no entrance to hand to an engine.
Custom colors and count
Any CSS color works, including tokens.
import { SparklesText } from "@glinui/ui"
export function Demo() { return ( <SparklesText sparklesCount={16} colors={{ first: "var(--color-signal-live)", second: "var(--color-accent)" }} > Shipped </SparklesText> )}Accessibility
- The text is real DOM text and is read normally.
- Every sparkle is a decorative svg with aria-hidden and is pointer-events none.
- No flashing: sparkles scale and fade over about one second each.
ARIA Attributes
- `aria-hidden` on every sparkle
Reduced Motion
With prefers-reduced-motion or motion level none or subtle, the animated pool is replaced by two static stars.
Affected properties
sparkle scalerotationopacityAPI Reference
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
children | React.ReactNode | Yes | - | The text to decorate. Required. |
as | "div" | "span" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | No | div | Element to render. |
sparklesCount | number | No | 10 | Sparkles alive at once. Capped at 24. |
colors | SparklesTextColors | No | accent, signal-ok tokens | Sparkle colors, any CSS color. |
Source
Import directly from the package or browse the source on GitHub. Click any file to view it.
Import
import { SparklesText } from "@glinui/ui"Dependencies
@glinui/ui@glinui/motionGenerated API Snapshot
Beta
Generated API Snapshot
BetaAuto-extracted from TypeScript source in packages/ui/src/components/sparkles-text.tsx. This section is in beta and may lag behind hand-curated docs. Regenerate with pnpm --filter @glinui/docs api:generate.
Generated: 2026-10-08T01:41:21.546Z · Full index: /docs/api-metadata
Primary Props Type
SparklesTextProps
SparklesTextProps
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
as | "div" | "span" | "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | No | "div" | Element to render. |
children | React.ReactNode | Yes | - | - |
colors | SparklesTextColors | No | DEFAULT_COLORS | Sparkle colors. Any CSS color, defaults to Glin tokens. |
sparklesCount | number | No | 10 | Number of sparkles alive at once. Capped at 24. |