Backgrounds

Sparkles Bg

A twinkling starfield background with configurable density and color.

A starfield background drawn on a 2D canvas, where every star twinkles on its own sine wave. Density and color are both adjustable, and the star count is derived automatically from the container's area.

Bring this into your project

Run this command in your project folder. The CLI adds the source and dependencies; then follow the usage example below.

npx webberui@latest add sparkles-bg.en

New project or installation trouble? Start here →

Playground

Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.

1
1
1.6
Active edited usageDefault props
<SparklesBg/>

The complete example includes the preview layout and data. Install the component first, then paste this file into your project.

Installation

npx webberui@latest add https://webberui.com/r/sparkles-bg.en.json

Or, once registries are configured in components.json, install it as @webberui/sparkles-bg.

Usage

import { SparklesBg } from "@/components/ui/sparkles-bg";

<SparklesBg density={1.4} color="#ffffff" background="#050506" className="h-[320px] w-full rounded-xl">
  <div className="flex h-full items-center justify-center text-white">
    Sparkles
  </div>
</SparklesBg>

Props

PropTypeDefaultDescription
densitynumber1Star density multiplier; the total is derived from the container's area
colorstring"#ffffff"Star color; accepts any CSS color value
minSizenumber0.6Minimum star radius (px)
maxSizenumber1.6Maximum star radius (px)
speednumber1Twinkle speed multiplier; 1 is the default cadence
backgroundstring"transparent"Background color; set transparent to layer it over an existing base color
childrenReactNode—Foreground content layered above the stars

Accessibility

  • When the user has "reduce motion" enabled at the system level, the stars are drawn statically once and no longer twinkle
  • The canvas carries aria-hidden and pointer-events-none — decorative only, so it interferes with neither interaction nor announcement