shadcn.io is not affiliated with official shadcn/ui
Sparkles fills its box with warm golden light in two depths: fine far dust, and nearer glowing points with a soft halo, each brightening and dimming on its own. Every few seconds a four-point glint, two crossed rays around a hot core, springs in, turns and fades; two to four are usually in the air. The points are repeating tiles the browser draws once, and a soft pattern of light and dark slides under each depth, so each point twinkles as the patches pass. The glints are gradients on keyframes, so there's no particle engine, canvas or script running. The gold is deeper on a light page so it shows on paper, and paler, with white-hot glints, at night.
Use it under a headline or behind a hero for a festive or magical touch. For warm lights that wander use Fireflies; for golden motes in a shaft of light, Pollen; for a still sky crossed by streaks, Shooting Stars.
Installation
Usage
import { Sparkles } from "@/components/ui/sparkles";<Sparkles className="min-h-[420px]">
<h1>A little magic</h1>
</Sparkles>Sparkles is a container: put your content inside and the sparkles sit behind it. It fills the box you give it, so set its height (min-h-[420px]), or className="fixed inset-0 -z-10" to cover the whole page.
Demos
Under a headline
A strip of sparkles to sit under a title, the classic layout: a 10rem box with density={1.5}, faded out from the top centre by a mask on its className.
Ice
sparkleColor takes any CSS colour, here a pale icy blue; density thins the dust and count={20} adds glints. The card stays dark in both themes (the dark class with bg-background).
Accessibility
The sparkles are decoration: the whole layer is hidden from screen readers and ignores the pointer, and your content inside reads as usual. With reduced motion the points hold still, each at its own brightness, and the glints stay hidden. The points change gradually, which is sparkle rather than flashing, and the glints are capped at three a second however many there are or however fast they run. Headlines in the foreground colour stay clear; behind small body text keep density at 1 or below, or fade the field with fade.
FAQ
Does it need a particle library?
No. The points are SVG tiles drawn once and used as masks, the twinkle is a soft pattern sliding under them, and the glints are gradients on keyframes. Nothing loads and no frame loop runs.
How do I control how many sparkles appear?
density scales the far dust, from 0.25 to 2: 1 is about 330 points on a 1280×720 screen, over about 75 nearer glowing points that stay. count sets the glints, from 0 (points only) to 40.
Can I make the dust bigger or smaller?
minSize and maxSize set the far dust's diameters in pixels, 1 to 2.5 by default. For finer dust try 0.5 to 1.5; for bolder points, 2 to 4.
How do I change the colour or background?
sparkleColor takes any CSS colour; by default it's a warm gold, deeper on a light page and paler at night, where the glints' cores turn white-hot. The background is whatever the container has: give it a bg-* class.
API Reference
Sparkles
<div> data-slot="sparkles"
count?number
How many four-point glints pop in and out, from 0 to 40; 0 leaves only the twinkling points. With many glints each pops less often, so no more than three pop a second.
- Default
12
density?number
How dense the far dust is, from 0.25 to 2: 1 is about 330 points on a 1280×720 screen. The nearer glowing sparkles (about 75) stay.
- Default
1
fade?"none" | "radial" | "top" | "bottom"
Where the sparkles fade out: toward every edge, toward the top, toward the bottom, or nowhere.
- Type
"none" | "radial" | "top" | "bottom"- Default
"none"
maxSize?number
The largest dust point's diameter, in pixels. @default 2.5.
- Default
2.5
minSize?number
The smallest dust point's diameter, in pixels. @default 1.
- Default
1
sparkleColor?string
The sparkles' colour, any CSS colour.
- Default
a warm gold, deeper in light mode so it shows on paper
speed?number
How fast the points twinkle and the glints pop, as a multiplier, from 0.25 to 3.
- Default
1
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
--sparkles-colorstring
The sparkles' colour (a warm gold).
--sparkles-speedstring
How fast they twinkle and pop (1).
Related
- Pro


Fireflies Background
ParticlesWarm glowing lights that wander


Particles
ParticlesDust drifting in depth, leaning toward the pointer
- Pro


Bokeh Background
ParticlesSoft out-of-focus circles


Starfield Background
SpaceFlying through stars
- Pro


Snow Background
WeatherFalling flakes
- Pro


Streaks over a still sky