For Tailwind CSS v3 docs, click here.

Stars Background

A parallax-animated starfield background using layered motion and randomized star positions.

API

Prop NameTypeDefaultDescription
factornumber0.05Multiplier for mouse parallax movement.
speednumber50Base speed (in seconds) for vertical looping animation of star layers.
transitionSpringOptions{ stiffness: 50, damping: 20 }Spring physics config for smooth motion response to cursor movement.
starColorstring"#fff"Color of the stars. Accepts any valid CSS color value.
classstringOptional additional classes for container div. Useful for z-index, etc.

💡 This component wraps a slot for children, so you can place other UI elements over the background.

Install using CLI

npm
pnpm
bun
yarn
npx shadcn-vue@latest add "https://registry.inspira-ui.com/bg-stars.json"

Install Manually

StarsBackground.vue

Features

  • Animated starfield: Renders three independently scrolling layers of stars with varying sizes and density.
  • Parallax effect: Responds to mouse movement with smooth spring physics, adding depth and realism.
  • Customizable star density: Each layer uses a different number of stars for natural variation.
  • Slot support: Acts as a visual container, allowing foreground UI or content to be layered on top.
  • Responsive

Credits