Backgrounds

Stars Background

Animated starfield background with customizable density and twinkling effects.

The StarsBackground component creates an animated starfield background with customizable star density and twinkling effects. It's perfect for adding a cosmic background to your UI.

Usage

Stars Background

Animated starfield background

<template>
  <div class="relative h-64 w-full overflow-hidden rounded-lg border bg-gradient-to-br from-gray-900 to-black">
    <MStarsBackground />
    <div class="relative z-10 h-full flex flex-col items-center justify-center text-center p-4">
      <h3 class="text-2xl font-bold text-white mb-2">
        Stars Background
      </h3>
      <p class="text-dimmed">
        Animated starfield background
      </p>
    </div>
  </div>
</template>

Examples

Basic Stars Background

Starfield Background

Create an immersive starfield background with twinkling stars for a cosmic user experience

<template>
  <div class="relative h-96 w-full overflow-hidden rounded-xl border bg-gradient-to-br from-gray-900 to-black">
    <MStarsBackground />
    <div class="relative z-10 h-full flex flex-col items-center justify-center text-center p-8">
      <div class="mb-8">
        <div class="w-20 h-20 rounded-full bg-gradient-to-r from-blue-400 to-purple-500 flex items-center justify-center mx-auto">
          <UIcon
            name="i-lucide-sparkles"
            class="w-10 h-10 text-white"
          />
        </div>
      </div>
      <h2 class="text-4xl font-bold text-white mb-6">
        Starfield Background
      </h2>
      <p class="text-dimmed max-w-md mb-8 text-lg">
        Create an immersive starfield background with twinkling stars for a cosmic user experience
      </p>
      <div class="flex flex-col sm:flex-row gap-4">
        <UButton
          color="primary"
          variant="solid"
          size="lg"
        >
          Explore Universe
        </UButton>
        <UButton
          color="neutral"
          variant="outline"
          size="lg"
        >
          View Demo
        </UButton>
      </div>
    </div>
  </div>
</template>

Customize

Customize

Star Density0.00015
All Stars Twinkle
Twinkle Probability0.7
Min Twinkle Speed0.5
Max Twinkle Speed1

Props

Prop Type Default Description
starDensitynumber0.00015Density of stars in the background (stars per pixel).
allStarsTwinklebooleantrueWhether all stars should twinkle.
twinkleProbabilitynumber0.7Probability that a star will twinkle (0-1).
minTwinkleSpeednumber0.5Minimum twinkling speed.
maxTwinkleSpeednumber1Maximum twinkling speed.
classstring''CSS classes to apply to the canvas container.

UI

This component's theme exposes the slots below. Override any of them per instance with the ui prop, or app-wide under ui.starsBackground in app.config.ts.

Prop Type Default Description
uiobject-Per-slot classes merged over the theme defaults.
Slot Props Description
root-h-full w-full absolute inset-0
Copyright © 2026