Liquid Gradient

Interactive liquid atmosphere rendered with vanilla WebGL (no Three.js). Colors follow VD3 UI primary, neutral, and background tokens and update live with light/dark theme changes. Move the pointer over the demo to ripple the surface.

Live demo

Use the site theme switcher to flip light/dark and primary — the gradient rebinds automatically. Drag the knobs to override --vd-liquid-* on this host.

Move pointer · theme-aware primary + neutrals
Markup
API reference

Wiring

import { ref } from 'vue';
import { useLiquidGradient } from "@vanduo-oss/vd3";

const root = ref<HTMLElement | null>(null);
useLiquidGradient(root);
// Scans .vd-liquid-gradient hosts; starts when .vd-liquid-gradient-active
// (or data-vd-liquid-active) is present. Theme + --vd-liquid-* sync automatically.

Factory (framework-agnostic)

Classes & attributes

Class / attributeApplies toEffect
.vd-liquid-gradienthostRequired host. Holds --vd-liquid-* knobs; decorative (pointer-events: none).
.vd-liquid-gradient-canvaschildWebGL canvas. Auto-created by useLiquidGradient if missing.
.vd-liquid-gradient-activehostVisible + running. Without it the engine stays stopped.
data-vd-liquid-activehostAlternate active flag (any value except "false").
.vd-liquid-gradient-fixedhostposition: fixed; inset: 0 — full-viewport atmosphere.
.vd-liquid-gradient-fillhostposition: absolute; inset: 0 — fill a positioned parent.

Customization tokens

TokenDefaultRole
--vd-liquid-speed1.15Orbit / animation speed multiplier
--vd-liquid-intensity1.35Overall color intensity
--vd-liquid-grain0.05Film-grain overlay strength
--vd-liquid-distort0.48Pointer UV distortion strength
--vd-liquid-gradient-size0.48Radial blob radius
--vd-liquid-primary-weight0.85Primary color contribution
--vd-liquid-neutral-weight1.15Neutral color contribution
--vd-liquid-alpha1Fragment output alpha

Theme colors come from --vd-color-primary-rgb / --vd-color-primary, --vd-neutral-2/6/8, and --vd-bg-primary, mixed differently for data-theme="light" vs dark.

Accessibility
  • Mark the host aria-hidden="true" — it is decorative.
  • prefers-reduced-motion: reduce draws a static frame (speed/distort = 0, no pointer trails).
  • If WebGL is unavailable, the factory returns null and the composable no-ops without throwing.
  • Host uses pointer-events: none so UI above remains clickable; pointer sampling is window-level while active.
Attribution

Inspired by the MIT-licensed CodePen “Interactive Liquid Gradient using Three.js” by Cameron Knight. VD3 UI ships a vanilla WebGL reimplementation bound to theme tokens and --vd-liquid-* knobs — no Three.js CDN.