# Blast — WebGL Background for React

> An audio-reactive furnace: a horizon coal bed whose glow and flame-lick height follow amplitude, with bass strikes hurling ember volleys upward and treble adding spark flicker. Degrades to a gently breathing coal bed without audio — never black. Mic capture only behind an explicit user gesture, with full AudioContext and GL teardown on unmount.

- Page: https://crucibleui.com/components/backgrounds/blast
- Category: [backgrounds](https://crucibleui.com/backgrounds)
- Tier: pro (one-time purchase, see https://crucibleui.com/pricing)
- Engine: ogl
- npm dependencies: ogl

## Install

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

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

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

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 (`BlastProps`)

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `source?` | `BlastSource` | `null` | Audio source driving the furnace. **"mic" must only be set in response to an explicit user gesture** (e.g. an "Enable microphone" button) — the component requests `getUserMedia` as soon as it sees the value. A media element is analysed and routed on to the speakers; note the platform restriction that an element can only ever feed one MediaElementSourceNode, so keep the same element instance across renders. Without a source the furnace degrades to a gentle breathing idle. |
| `sensitivity?` | `number` | `1` | Input gain applied to the analysed signal. |
| `smoothing?` | `number` | `0.65` | Analyser smoothing (0–0.95): higher values make the coals swell and relax lazily, lower values track the signal nervously. |
| `colors?` | `[string, string, string]` | — | Forge triplet: `[molten, ember, deep]`. Molten paints the hottest coals and ember tips, ember the body of the glow, deep the cold smoke above. |
| `idleIntensity?` | `number` | `0.6` | Brightness of the no-audio "breathing coal bed" fallback (0–1). 0 still leaves a faint floor — the furnace is never black. |
| `speed?` | `number` | `1` | Idle-breathing and flicker speed multiplier. |
| `intensity?` | `number` | `1` | Overall brightness multiplier. |
| `heat?` | `number` | `1` | Forge heat (0–1): scales glow, ember energy, and spark brightness together. |
| `paused?` | `boolean` | — | Freeze the render loop, holding the current frame. |
| `onAudioError?` | `(error: unknown) => void` | — | Called when an audio source fails (mic denied, unsupported element, …). The furnace has already fallen back to its idle breathing by then. |
| `className?` | `string` | — | Extra classes for the wrapper. Positioned `absolute inset-0 -z-10`. |

## Usage example

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

```tsx
"use client";

import * as React from "react";

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

// Skips the shared DemoScene wrapper: the mic-toggle button is the demo's
// interaction and would fight the fake-hero overlay.
export default function BlastDemo() {
  const [micOn, setMicOn] = React.useState(false);
  const [failed, setFailed] = React.useState(false);
  // Site embeds (thumbnails, mosaics) ask for the bare effect — mirror what
  // DemoScene's raw mode does for demos that use it.
  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">
        <Blast source={null} />
      </div>
    );
  }

  return (
    <div className="relative isolate flex h-full min-h-[360px] w-full items-center justify-center overflow-hidden rounded-xl bg-neutral-950">
      <Blast
        source={micOn ? "mic" : null}
        onAudioError={() => {
          setMicOn(false);
          setFailed(true);
        }}
      />
      <div className="relative z-10 flex flex-col items-center px-6 text-center">
        <p className="text-3xl font-semibold tracking-tight text-white drop-shadow-[0_2px_12px_rgba(0,0,0,0.7)]">
          Give it a signal
        </p>
        <p className="mt-2 max-w-sm text-sm text-white/70">
          The field breathes on its own. Enable the microphone and it
          answers — bass throws embers, treble spits sparks.
        </p>
        <button
          type="button"
          aria-pressed={micOn}
          onClick={() => {
            setFailed(false);
            setMicOn((v) => !v);
          }}
          className="mt-6 rounded-full border border-white/15 bg-white/5 px-5 py-2 text-sm font-medium text-white transition-colors hover:border-amber-500/60 hover:bg-amber-500/10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-500"
        >
          {micOn ? "Mute microphone" : "Enable microphone"}
        </button>
        {failed && (
          <p role="status" className="mt-3 text-xs text-white/50">
            Microphone unavailable — the field keeps breathing on its own.
          </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.
