Vanilla Breeze

bg-wc

A theme-aware graphics layer. <bg-wc> renders an animated WebGL or Canvas2D background behind any HTML content, picking the right renderer per preset. It reads the same --color-* tokens Vanilla Breeze themes set on :root, so it re-skins automatically when you switch theme packs — and it can be applied without writing a custom element at all, via data-background attributes.

Where to find it

Install

Via CDN:

Or via npm:

Not bundled into Vanilla Breeze — wire it in yourself. There is no build coupling between the two repos; the interface is purely CSS custom properties.

Two ways to apply it

1. As a custom element

Wrap your content. The content stays in the light DOM and renders above the animated layer:

2. As data-background attributes (no custom element)

Import the binder once, then decorate any existing element with data-background and matching data-background-* attributes. The binder injects a <bg-wc> behind that element's content — handy when you don't want to restructure your markup:

Add data-background-skip to an element to opt it out of binding. For dynamically inserted DOM, call bindDataBackgrounds(root) after import.

Demos

Each demo loads a default-theme Vanilla Breeze page and fills the frame with a single background. Switching the page's data-theme would re-skin each one, since they read VB tokens directly.

mesh-gradient (WebGL custom element)

mosaic (via the data-background binder)

confetti (Canvas2D, semantic palette)

Attributes

AttributeValuesDefaultPurpose
presetpreset nameRequired. Which effect to render (see below).
palettetheme / rainbow / monothemeColor strategy. theme pulls VB tokens.
intensity0–10.5Per-preset drama / strength.
speed0–51Time multiplier; 0 freezes the animation.
density0–10.5Particle count or shader detail.
seedinteger0Deterministic randomization.
pausedbooleanunsetPauses the render loop without unmounting.
pixel-rationumbermin(devicePixelRatio, 2)Override render pixel density.
qualitylow / med / highmedRenderer-level quality hint.
fitcover / contain / stretchcoverSurface sizing behavior.
motionauto / reduce / forceautoReduced-motion handling (see below).
textstringPayload for text presets; lines split on |.
modestringUsed by mosaic: isometric, flat, sparse, stacked.
use-themebooleanunsetEnables theme-token coloring for system7.

data-background attributes

After importing @profpowell/bg-wc/data-background, every attribute below maps to the matching <bg-wc> attribute or custom property on the injected element.

data-* attributeMaps to
data-backgroundpreset (required)
data-background-intensityintensity
data-background-speedspeed
data-background-densitydensity
data-background-seedseed
data-background-palettepalette
data-background-qualityquality
data-background-fitfit
data-background-motionmotion
data-background-pausedpaused
data-background-pixel-ratiopixel-ratio
data-background-color-1--bg-wc-color-1
data-background-color-2--bg-wc-color-2
data-background-color-3--bg-wc-color-3
data-background-color-bg--bg-wc-color-bg
data-background-color-fg--bg-wc-color-fg
data-background-skipescape hatch — prevents binding

Presets

Dozens of presets ship across two renderers. The current catalog:

WebGL (shader) presets

dither, noise, mesh-gradient, warp, waves, lava, plasma, aurora, tunnel, caustics, glitch, rainbow, halftone, kaleidoscope, vhs, synthwave, crt, gameboy, copperbars, topology, cells, shine, conic, grain, trench, marble, benday, comic, deco, bliss

Canvas2D presets

GroupPresets
Vector / arcadeasteroids, wireframe, spirograph, incoming, tempest, fireworks
Textcrawl, marquee, sinescroll, cascade
Dataviztrades, dashboard, vectormap, scatter, waveform, wordcloud
Particlesstars, snow, confetti, network, particles, pulse, tetris, matrix, mystify
Pattern / geometricmosaic, ribbons, source, system7

For the live gallery see the component docs.

Theme tokens

The renderer reads these VB tokens once per frame, with built-in fallbacks so it still works on a non-VB page:

TokenRoleFallback
--color-backgroundCanvas backdroptransparent
--color-foregroundDefault line / particle color#1a1a1a
--color-primaryPrimary tint#3b82f6
--color-accentAccent tint#ec4899
--color-infoTertiary tint#10b981
--color-success / --color-warning / --color-errorSemantic palette (e.g. confetti)green / amber / red

Per-instance overrides via the component's own namespace always win:

PropertyOverrides
--bg-wc-color-1--color-primary
--bg-wc-color-2--color-accent
--bg-wc-color-3--color-info
--bg-wc-color-bg--color-background
--bg-wc-color-fg--color-foreground
--bg-wc-intensity / --bg-wc-speed / --bg-wc-densitythe matching attribute

The internal <canvas> is exposed as part="canvas" for further styling.

JavaScript API

Methods and properties on the element:

MemberBehavior
.presetReflects the preset attribute.
.pausedReflects the paused attribute.
.pause()Pauses the render loop.
.resume()Resumes the render loop.
.snapshot()Resolves to a PNG Blob of the current frame.
.readyPromise that resolves after the first frame renders.

Events it dispatches:

EventDetailWhen
bg-wc:ready{ preset, renderer }First frame rendered.
bg-wc:preset-changed{ from, to }After a successful preset swap.
bg-wc:error{ phase, error }Compile, load, or runtime error.
bg-wc:visibility{ visible }IntersectionObserver gate flips.

Performance & reduced motion

Usage

Custom properties declared on :root — which is exactly what VB themes do — inherit through the shadow boundary, so no piercing is required.