# Sparkles Text

> Headline text with four point stars that twinkle around it in your accent colors. The sparkles are decorative and hidden; the text stays plain and readable.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/sparkles-text
- Source (registry JSON with the full file): https://ui.minidev.pro/r/sparkles-text.json
- License: MIT. One file, yours to edit after install.

## When to use

Use it for one short celebratory word or phrase. Reach for GradientText for a still accent and ConfettiButton for a one-off burst on success.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/sparkles-text
```

Writes `components/ui/sparkles-text.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/sparkles-text.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { SparklesText } from "@/components/ui/sparkles-text"
```

From the npm package:

```tsx
import { SparklesText } from "minidev-ui-kit/premium/sparkles-text"
```

## Usage

```tsx
import { SparklesText } from "@/components/ui/sparkles-text"

export function Example() {
  return (
    <SparklesText />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `children` | `React.ReactNode` | `"Magic, but tasteful"` | no | The text that sparkles. Stays a plain text node for search and screen readers. |
| `count` | `number` | `8` | no | How many stars are alive at once. |
| `className` | `string` | - | no |  |

## Examples

### Custom text

The text is a normal text node; stars are decorative and hidden from assistive tech.

```tsx
<SparklesText>Lumen 3.0 is here</SparklesText>
```

### More stars, smaller text

count is how many stars are alive at once; size the text with className.

```tsx
<SparklesText count={16} className="text-2xl sm:text-3xl">Autopilot for invoices</SparklesText>
```

### Inside a headline

Match the headline's size and weight with className to sparkle one phrase in a longer line.

```tsx
<h2 className="max-w-lg px-4 text-center text-3xl font-medium tracking-[-0.035em] text-fg sm:text-4xl">
  Close the books with <SparklesText count={6} className="text-3xl font-medium sm:text-4xl">zero chasing</SparklesText>
</h2>
```

## Accessibility

- Each star is an `aria-hidden` SVG with `pointer-events-none`; the text stays a normal text node.
- It renders a `<span>`. Wrap it in a heading if the phrase is a heading.
- Under reduced motion no stars appear.

## FAQ

### Does SparklesText keep running off screen?

No. New stars only spawn while the text is in view, one every 420ms, and none spawn under reduced motion. `count` sets how many are alive at once (default 8).

### Why are there no sparkles in the server HTML?

Stars are created with random positions in an effect after mount, so the server renders only the text and hydration matches.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Text](https://ui.minidev.pro/docs/text/md): Text paragraph primitive with muted, subtle and mono variants on top of your base type styles. Keeps secondary copy and inline technical text consistent.
- [Gradient Text](https://ui.minidev.pro/docs/gradient-text/md): Headline text filled with a slowly drifting gradient built from your accent tokens. A real text node for SEO and screen readers, still for reduced motion.
- [Confetti Button](https://ui.minidev.pro/docs/confetti-button/md): A React button that bursts confetti from itself on click, with gravity, drag and spin on a temporary canvas. No library, and skipped for reduced motion.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.
- [Cursor Spotlight Panel](https://ui.minidev.pro/docs/cursor-spotlight-panel/md): A panel whose accent radial spotlight follows the cursor, driven by Framer Motion values without re-renders. It shows a still surface for reduced motion.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
