# Crucible — WebGL Background for React

> A sealed glass vessel of molten-metal spheres that tumble in and settle under a heat glow. Instanced rigid bodies, bloom, pointer stirring, offscreen-paused, and reduced-motion-safe; idles on its own when untouched — a ghost hand stirs and strikes.

- Page: https://crucibleui.com/components/backgrounds/crucible
- Category: [backgrounds](https://crucibleui.com/backgrounds)
- Tier: pro (one-time purchase, see https://crucibleui.com/pricing)
- Engine: r3f
- npm dependencies: three, @react-three/fiber, @react-three/rapier, @react-three/postprocessing

## Install

```bash
npx shadcn@latest add @crucible/crucible
```

Pro install requires adding the token-bearing `@crucible` registry to components.json (issued at https://crucibleui.com/account after purchase).

Import from `@/components/crucible/crucible`.

Backgrounds render `absolute inset-0 -z-10`. Their parent must be a stacking context — wrap in `relative isolate` and put your content in a `relative z-10` child, or the background disappears behind an opaque ancestor.

## Props (`Props`)

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `count?` | `number` | `48` | How many molten spheres are sealed in the vessel. Rendered as a single instanced draw call, so higher counts stay cheap. |
| `colors?` | `[string, string]` | `a warm bronze / molten-amber forge palette` | Two hex colors: `[metalTint, emissiveCore]`. The first is the metallic surface albedo, the second the glowing amber core. |
| `intensity?` | `number` | `1` | Master brightness for the emissive cores, heat lights, and bloom. 1 = default, push toward 1.5 for a white-hot pour. |
| `interactive?` | `boolean` | `true` | Enable pointer stirring (drag to nudge spheres) and click strikes. Automatically disabled on touch / coarse-pointer devices. |
| `idle?` | `boolean` | `true` | Idle autoplay: after ~1.5s with no real pointer (and always on touch devices), a seeded ghost hand slowly stirs the melt and lands an occasional strike, so thumbnails and heroes never sit still; the real pointer takes over instantly. Requires `interactive`. Never runs under reduced motion. |
| `paused?` | `boolean` | `false` | Freeze the simulation with the spheres in a settled, aesthetic pile. Also forced on when the user prefers reduced motion. |
| `className?` | `string` | — | Extra classes for the wrapper. Positioned `absolute inset-0 -z-10`. |
| `ref?` | `React.Ref<CrucibleHandle>` | — | React 19 ref prop → {@link CrucibleHandle}. |

## Usage example

`DemoScene` is a site-only preview harness, not part of the component — replace it with your own layout.

```tsx
import * as React from "react";

import { DemoSceneContext } from "@/components/registry/demo-scene";
import { Crucible } from "@/components/crucible/crucible";

// Skips the shared DemoScene wrapper: drag/click across the whole stage is
// the demo's interaction, and a full-bleed hero overlay would swallow it.
export default function CrucibleDemo() {
  // Site embeds (thumbnails, mosaics) ask for the bare effect — mirror what
  // DemoScene's raw mode does for demos that use it. Drag/click still works.
  const embed = React.useContext(DemoSceneContext);

  if (embed?.raw) {
    return (
      <div className="relative isolate h-full min-h-0 w-full overflow-hidden rounded-xl bg-neutral-950">
        <Crucible />
      </div>
    );
  }

  return (
    <div className="relative isolate flex h-full min-h-[420px] w-full items-center justify-center overflow-hidden rounded-xl bg-neutral-950">
      <Crucible />
      <div className="relative z-10 max-w-md rounded-2xl bg-neutral-950/45 px-8 py-6 text-center shadow-[0_8px_40px_rgba(0,0,0,0.45)] ring-1 ring-white/10 backdrop-blur-[2px]">
        <p className="text-3xl font-semibold tracking-tight text-white drop-shadow-[0_2px_12px_rgba(0,0,0,0.85)]">
          Physics you can feel
        </p>
        <p className="mt-2 text-sm text-white/85 drop-shadow-[0_1px_6px_rgba(0,0,0,0.9)]">
          Glowing spheres tumble and settle inside a sealed glass vessel. Drag to stir, click to strike.
        </p>
      </div>
    </div>
  );
}
```

## Accessibility & performance

Honors `prefers-reduced-motion` with a designed static frame or fade (never a blank box) and passes `className` through. Pauses offscreen and on hidden tabs, clamps device pixel ratio, and tears down its GL/canvas context on unmount.
