Skip to content

Light Field

Motion

A WebGL shader background of drifting color silk with a soft cursor light and grain. It renders at half resolution, pauses offscreen and adapts to dark mode.

src/registry/premium/light-field.tsx/r/light-field.json

Installation

bash
npx shadcn@latest add @minidev/light-field

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/light-field.json

Usage

tsx
import { LightField } from "@/components/ui/light-field"

export function Example() {
  return (
    <LightField />
  )
}

API reference

LightField props
PropTypeDefault
classNamestring-
paletteThree RGB colours (0 to 1 per channel) per theme: base, partner and highlight.{ light?: Palette; dark?: Palette }-
fpsFrames per second. The silk drifts slowly, so 30 looks the same as 60 for half the GPU work.number30
resolutionRender scale in CSS pixels. The field is soft, so 0.5 (scaled up by the browser) is indistinguishable from full size.number0.5

When to use

It fills its parent: put it in a sized, relative box with your content layered above. Reach for AuroraBackground or HeroGradientMesh for a CSS-only backdrop, and WavyBackground or Particles for a lighter canvas effect.

Accessibility

  • The canvas is aria-hidden; it carries no content.
  • Reduced motion is read once when the shader starts: it then draws one still frame and does not animate.

Frequently asked questions

Why is LightField blank on some machines?

It asks for WebGL with failIfMajorPerformanceCaveat and skips software renderers (SwiftShader, llvmpipe), so machines without a real GPU get an empty canvas. Put a still image or gradient behind it as a fallback.

How do I size it and layer content on top?

It fills its parent. Put it in a sized relative box with className="absolute inset-0", and give your content relative z-10. The canvas fades in over 700ms on its first frame.

Does it follow dark mode?

Yes, when the dark class is on <html>: a MutationObserver switches between palette.light and palette.dark. Each palette is three RGB triples with channels from 0 to 1.

How heavy is it?

It starts in requestIdleCallback, renders at half resolution (resolution={0.5}) and 30 fps (fps), and stops when off screen or in a background tab. Lower both for weaker devices.

Examples

Hero backdrop

LightField fills its parent: put it in a sized, relative box and layer the content above with z-10.

Calmer palette for a sign-in panel

Each theme takes three RGB triples (0 to 1): base, partner and highlight. A lower fps suits a small, quiet panel.

All Animated React components