npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@russellio/vue-background-stars

v1.2.2

Published

A beautiful animated starry night sky background component for Vue 3 with optional toggle control

Downloads

580

Readme

Vue Background Stars

An animated starfield background component for Vue 3. It is intended for projects that need a lightweight, configurable night-sky effect without bringing in a canvas renderer or animation dependency.

npm version npm downloads CI License: MIT Vue.js TypeScript

Live demo

Contents

Features

  • Vue 3 component with TypeScript definitions
  • Configurable star count, density, color palette, and animation speed
  • Respects prefers-reduced-motion; animations can also be disabled with a prop
  • Generates the star layers on mount with requestAnimationFrame
  • Includes an optional ToggleSwitch component for simple visibility controls
  • Ships ESM, UMD, CSS, and declaration files
  • No runtime dependencies beyond Vue

Installation

npm install @russellio/vue-background-stars
yarn add @russellio/vue-background-stars
pnpm add @russellio/vue-background-stars

Usage

Import the component and stylesheet where you need the background.

<script setup lang="ts">
import { BackgroundStars } from '@russellio/vue-background-stars';
import '@russellio/vue-background-stars/style.css';
</script>

<template>
  <BackgroundStars />
</template>

The component renders as a fixed background with z-index: -1, so your page content should establish its own stacking context when needed.

<script setup lang="ts">
import { ref } from 'vue';
import { BackgroundStars, ToggleSwitch } from '@russellio/vue-background-stars';
import '@russellio/vue-background-stars/style.css';

const showStars = ref(true);
</script>

<template>
  <main class="page">
    <ToggleSwitch v-model="showStars" label="Starfield" />
    <BackgroundStars v-if="showStars" />

    <section class="content">
      <h1>Launch Console</h1>
    </section>
  </main>
</template>

<style scoped>
.page {
  position: relative;
  min-height: 100vh;
  color: white;
}
</style>

Plugin Install

You can register both components globally with the default plugin export.

import { createApp } from 'vue';
import VueBackgroundStars from '@russellio/vue-background-stars';
import '@russellio/vue-background-stars/style.css';
import App from './App.vue';

const app = createApp(App);

app.use(VueBackgroundStars);
app.mount('#app');
<template>
  <BackgroundStars />
  <ToggleSwitch v-model="showStars" label="Starfield" />
</template>

API

BackgroundStars

Renders the animated starfield. The component builds several box-shadow based layers from a single coordinate space, which keeps the DOM small while still allowing dense star patterns.

Props

| Prop | Type | Default | Description | | ------------------ | --------------------------------- | -------------------------- | ---------------------------------------------------------------------------------------- | | starCount | number | 1000 | Base star count used to generate the layer sizes. | | palette | readonly string[] | built-in night-sky palette | Colors used for the nebula glow layers. | | density | 'sparse' \| 'normal' \| 'dense' | 'normal' | Multiplies the generated count by 0.4, 0.8, or 2. | | speed | number | 0.8 | Animation duration multiplier. Values above 1 are slower; values below 1 are faster. | | disableAnimation | boolean | false | Disables blinking animations, independent of reduced-motion settings. |

Events

| Event | Description | | ------------------ | ------------------------------------------------------------------------- | | background-ready | Emitted after the star layers are generated on the first animation frame. |

<BackgroundStars @background-ready="handleBackgroundReady" />

Examples

<template>
  <!-- Fewer stars -->
  <BackgroundStars :star-count="500" density="sparse" />

  <!-- More stars, slower blink animation -->
  <BackgroundStars density="dense" :speed="2" />

  <!-- Static background -->
  <BackgroundStars disable-animation />

  <!-- Custom nebula colors -->
  <BackgroundStars :palette="['#07121f', '#1d4ed8', '#38bdf8', '#f8fafc']" />
</template>

ToggleSwitch

A small controlled switch component. It uses v-model and emits the standard update:modelValue event.

Props

| Prop | Type | Default | Description | | ------------ | --------- | ------- | -------------------------------------------------------- | | modelValue | boolean | false | Current switch state. | | label | string | '' | Optional visible label. | | showIcon | boolean | true | Shows the decorative star icon on desktop-sized screens. |

Events

| Event | Description | | ------------------- | ------------------------------------------------------------ | | update:modelValue | Emitted with the next boolean state when the switch changes. |

<script setup lang="ts">
import { ref } from 'vue';
import { ToggleSwitch } from '@russellio/vue-background-stars';

const enabled = ref(false);
</script>

<template>
  <ToggleSwitch v-model="enabled" label="Enable stars" />
</template>

Styling

Importing @russellio/vue-background-stars/style.css is required. The components include their base styles, but you can still override global selectors or set the toggle CSS variables from a wrapper.

.my-page {
  --toggle-track-bg: #1f2937;
  --toggle-track-bg-active: #38bdf8;
  --toggle-thumb-bg: #f8fafc;
  --toggle-focus-ring: rgba(56, 189, 248, 0.45);
}

| Variable | Default | Used by | | -------------------------- | --------- | ---------------------- | | --toggle-track-bg | #d1d5db | Toggle track when off | | --toggle-track-bg-active | #3b82f6 | Toggle track when on | | --toggle-thumb-bg | #ffffff | Toggle thumb | | --toggle-focus-ring | #3b82f6 | Keyboard focus outline |

For background-specific changes, override the generated classes from your app stylesheet.

.sky {
  background: radial-gradient(at 50% 35%, #0f172a 0, transparent 55%), #020617;
}

.star-small,
.star-med,
.star-large,
.star-bright {
  opacity: 0.7;
}

Browser Support

The package targets modern browsers that support Vue 3, CSS animations, and standard ES module output. It is tested against the current versions of Chrome, Firefox, Safari, and Edge.

Development

Install dependencies:

npm install

Run the demo app:

npm run dev

Build the package:

npm run build

Run checks:

npm run type-check
npm run test:run
npm run lint
npm run format:check

Common scripts:

| Script | Description | | ----------------------- | ----------------------------------------- | | npm run dev | Starts the Vite demo app. | | npm run build | Type-checks and builds the package. | | npm run preview | Serves the production demo build locally. | | npm run type-check | Runs vue-tsc --noEmit. | | npm test | Starts Vitest in watch mode. | | npm run test:run | Runs Vitest once. | | npm run test:coverage | Runs Vitest with coverage. | | npm run lint | Runs ESLint over src/. |

Build output is written to dist/ and includes:

  • vue-background-stars.es.js
  • vue-background-stars.umd.js
  • vue-background-stars.css
  • vue-background-stars.es.d.ts

Contributing

Issues and pull requests are welcome. For larger changes, open an issue first so the API or implementation direction can be discussed before code is written.

Before opening a pull request, please run the type check, tests, linting, and formatting check listed above. Updates that change runtime behavior should include tests and README updates where appropriate.

See CONTRIBUTING.md for the full contribution guide.

License

MIT. See LICENSE for details.

Credits

Built with Vue, Vite, and Vitest. Inspired by this CodePen.