Skip to content

Dotted Glow Background

An animated dotted background with glowing effects that supports dark mode.

Installation

bash
npx draft-cli vue add dotted-glow-background

Usage

Basic

Dotted Glow Background

vue
<script setup>
import { DottedGlowBackground } from '@draft-ui/vue'
</script>

<template>
  <div style="position: relative; height: 300px;">
    <DottedGlowBackground />
    <div style="position: relative; z-index: 1;">
      <!-- Your content here -->
    </div>
  </div>
</template>

You can customize colors, animation speed, and other properties via props.

API

PropTypeDefaultDescription
gapnumber12Distance between dots in pixels.
radiusnumber2Radius of each dot in pixels.
colorstring'rgba(0,0,0,0.7)'Base color of the dots in light mode.
darkColorstring-Base color of the dots in dark mode (falls back to color).
glowColorstring'rgba(0, 170, 255, 0.85)'Glow color in light mode.
darkGlowColorstring-Glow color in dark mode (falls back to glowColor).
colorLightVarstring-CSS variable name for light mode dot color.
colorDarkVarstring-CSS variable name for dark mode dot color.
glowColorLightVarstring-CSS variable name for light mode glow color.
glowColorDarkVarstring-CSS variable name for dark mode glow color.
opacitynumber0.6Overall opacity of the canvas (0-1).
backgroundOpacitynumber0Opacity of the radial gradient background (0-1).
speedMinnumber0.4Minimum animation speed multiplier.
speedMaxnumber1.3Maximum animation speed multiplier.
speedScalenumber1Global speed scale for all animations.
animatebooleantrueWhether to animate the dots.

Notes

  • The component uses position: absolute; inset: 0 so it needs to be placed inside a positioned container.
  • Content should be placed in a sibling element with position: relative and appropriate z-index to appear above the background.
  • The component automatically adapts to dark mode when using @vueuse/core's dark mode detection.
  • Uses ResizeObserver to automatically adjust to container size changes.