# Sandcast — Animated Text Effect for React

> Headline cast in fine gold sand: the text is sampled into grains that scatter with velocity and curl under the cursor, then trickle back home with staggered springs and a settling drift; idles on its own when untouched.

- Page: https://crucibleui.com/components/text/sandcast
- Category: [text](https://crucibleui.com/components/text)
- Tier: pro (one-time purchase, see https://crucibleui.com/pricing)
- Engine: canvas

## Install

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

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

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

## Props (`SandcastProps`)

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `text?` | `string` | `"SANDCAST"` | Headline cast in sand (also emitted as sr-only text). |
| `gap?` | `number` | `3` | Sampling gap in px between grains — smaller = denser, more particles. |
| `particleSize?` | `number` | `1.7` | Base grain size in px (each grain jitters around it). |
| `colors?` | `string[]` | `warm golds` | Grain palette, assigned per particle. Keep it a narrow single-hue ramp — the default is fine gold sand. |
| `scatterRadius?` | `number` | `100` | Pointer repulsion radius in px. |
| `strength?` | `number` | `1` | Pointer repulsion strength multiplier. |
| `stiffness?` | `number` | `1` | Return-spring stiffness multiplier — how eagerly grains trickle home. |
| `speed?` | `number` | `1` | Simulation-rate multiplier. |
| `paused?` | `boolean` | `false` | Freeze the simulation (grains hold their current positions). |
| `seed?` | `number` | `5` | Deterministic seed for grain jitter and the entrance drift. |
| `idle?` | `boolean` | `true` | Idle autoplay: after 1.5s with no pointer over the sand, a ghost hand makes an occasional slow pass through the word (a lighter brush than a real pointer), then rests so the letters heal crisp between passes. A real pointer takes over instantly. Never under reduced motion; sleeps offscreen and when paused. |
| `ref?` | `React.Ref<SandcastHandle>` | — | React 19 ref prop — imperative `replay()` of the blow-in entrance. |

Also accepts: `Omit<React.ComponentPropsWithoutRef<"div">, "children" | "color">`.

## Usage example

```tsx
import { Sandcast } from "@/components/crucible/sandcast";

export default function SandcastDemo() {
  return (
    <div className="relative isolate flex h-full min-h-[360px] w-full items-center justify-center overflow-hidden rounded-xl bg-neutral-950">
      <div className="relative z-10 flex w-full max-w-2xl flex-col items-center gap-5 px-6 py-8">
        <Sandcast text="SANDCAST" className="h-44 min-h-0 w-full" />
        <p className="text-sm text-neutral-500">Move your cursor through the letters</p>
        <div className="flex w-full flex-col items-center gap-2">
          <Sandcast
            text="Brush through me"
            colors={["#e2e8f0", "#94a3b8", "#f8fafc", "#64748b"]}
            gap={2}
            particleSize={1.9}
            className="h-28 min-h-0 w-full max-w-md"
          />
          <span className="text-[10px] font-medium uppercase tracking-[0.2em] text-neutral-600">
            Custom colors
          </span>
        </div>
      </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.
