# Light Field

> 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.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/light-field
- Source (registry JSON with the full file): https://ui.minidev.pro/r/light-field.json
- License: MIT. One file, yours to edit after install.

## 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.

## Installation

### shadcn CLI (copies the source into your project)

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

Writes `components/ui/light-field.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/light-field.json`.

### npm package

```bash
npm i minidev-ui-kit
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

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

From the npm package:

```tsx
import { LightField } from "minidev-ui-kit/premium/light-field"
```

## Usage

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

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

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `className` | `string` | - | no |  |
| `palette` | `{ light?: Palette; dark?: Palette }` | - | no | Three RGB colours (0 to 1 per channel) per theme: base, partner and highlight. |
| `fps` | `number` | `30` | no | Frames per second. The silk drifts slowly, so 30 looks the same as 60 for half the GPU work. |
| `resolution` | `number` | `0.5` | no | Render scale in CSS pixels. The field is soft, so 0.5 (scaled up by the browser) is indistinguishable from full size. |

## Examples

### Hero backdrop

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

```tsx
<div className="relative h-[360px] w-full overflow-hidden rounded-2xl border border-border bg-sunken">
  <LightField className="absolute inset-0" />
  <div className="relative z-10 flex h-full flex-col items-center justify-center gap-4 px-6 text-center">
    <p className="max-w-[18ch] text-3xl font-medium tracking-[-0.035em] text-balance text-fg">Forecasts that update as you sell</p>
    <Button>
      Try Northwind Plan <ArrowRightIcon />
    </Button>
  </div>
</div>
```

### 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.

```tsx
<div className="relative h-[280px] w-full max-w-md overflow-hidden rounded-2xl border border-border bg-sunken">
  <LightField
    className="absolute inset-0"
    fps={24}
    palette={{
      light: { c1: [0.6, 0.8, 0.95], c2: [0.75, 0.9, 0.85], c3: [0.9, 0.85, 1.0] },
      dark: { c1: [0.1, 0.3, 0.55], c2: [0.05, 0.4, 0.4], c3: [0.35, 0.25, 0.6] },
    }}
  />
  <p className="relative z-10 p-6 text-sm font-medium text-fg">Sign in to Acme Ledger</p>
</div>
```

## 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.

## FAQ

### 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.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Related

- [Aurora Background](https://ui.minidev.pro/docs/aurora-background/md): React aurora background that drifts soft, blurred bands of accent colour behind a hero, with intensity, speed, blur and colour props. Pauses off screen.
- [Hero Gradient Mesh](https://ui.minidev.pro/docs/hero-gradient-mesh/md): A dark hero on a layered radial gradient mesh with a scale in headline, supporting copy and high contrast launch and docs buttons for launch pages.
- [Wavy Background](https://ui.minidev.pro/docs/wavy-background/md): React canvas background of layered sine waves rolling behind your content, with colour, speed, amplitude and blur props, sharp on retina and paused off screen.
- [Particles](https://ui.minidev.pro/docs/particles/md): React canvas background of drifting particles that repel or attract around the pointer, colored from your accent token and sharp on high density screens.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
