Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Sparkles field, animated React component

A canvas layer of sparkles that pop in with a small overshoot, turn as they shine, drift and fade, then reappear elsewhere. With interactive on, the pointer leaves a sparkling trail and a click throws a burst that arcs down under gravity.

  • Free
  • Motion Effects
  • Hover

Like Sparkles field? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Sparkles field stays free.

Play with it

Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.

Props

PropTypeDefaultWhat it does
count36Base number of sparkles, before density scales it.
color—Sparkle colour. Defaults to blue on light, ice white on dark.
minSize0.9Smallest sparkle radius in px.
maxSize2.8Largest sparkle radius in px. The biggest fifth are drawn as four-point stars.
speed1Speed multiplier for twinkling and drift.
opacity0.9Overall opacity, 0.1 to 1.
className—Classes for layout and masking.
backgroundfalseMount as an absolute layer filling the parent.
density"medium"Density preset that scales count.
direction"random"Which way sparkles drift while they shine.
enableGlowtrueSoft bloom round each sparkle.
interactivefalsePointer trail and click bursts.
autoplayfalseThrows a few bursts until someone touches the layer.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for you:

    npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

    Type it exactly as shown. {name} is filled in by the CLI with the component you ask for, so you never replace it.

  1. 3

    Add the component

    Run this from your project root. It adds the component, the helpers it imports and its npm packages.

    npx shadcn@latest add @nexus-labs/sparkles
  2. 4

    Check what was added

    With a project made as in the Quick Start (a src/ folder), these files land in it:

    components/
    sparkles.tsx
    sparkles/
    index.ts
    sparkles.tsx
  3. 5

    Copying by hand? Skip the registry

    Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that cn() exists. Install the packages:

    npm install framer-motion

    Then show the source and create each file at the path it gives:

  4. 6

    Use it in a page

    Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:

    // src/app/page.tsx
    import { Sparkles } from "@/components/sparkles";
    
    export default function Page() {
      return (
        <main>
          <Sparkles />
        </main>
      );
    }

Like Sparkles field? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Sparkles field stays free.

About Sparkles field

The Sparkles component renders a field of randomly positioned, rotating star particles around its children. Particle positions, sizes, rotations, and colors are individually randomized on mount and re-randomized on a configurable timer using CSS animation. The effect creates a celebratory or magical visual context around headings, buttons, or icons. Zero JavaScript animation overhead during steady state — particles run on CSS keyframes after mount.

Good for

  • Hero heading decorative effects
  • CTA button visual emphasis
  • Achievement and reward UI displays
  • Promotional banner decorations

Sparkles field questions

How do I install the sparkles effect?

Run `npx shadcn@latest add @nexus-labs/sparkles`. It adds the Sparkles component and installs framer-motion.

How do I use it as a background?

Set `background` and it fills its nearest positioned parent as an absolute layer; otherwise size it with `className`. The page also shows line and starfield variations built from the same component.

Which props change how the particles look?

`count` (36) is scaled by `density` ("low", "medium", "high"). `minSize`/`maxSize`, `speed`, `opacity`, `color`, `direction` ("up", "down", "random") and `enableGlow` shape the rest.

Can it react to the mouse?

Yes. Set `interactive` to add a pointer glow, sparkles on hover and a burst of particles on click. With prefers-reduced-motion on, the particles stay still and dimmed.

Guides