# Anvil — Animated Button for React

> A magnetic button with the heft of forged iron — it leans toward the cursor with damped spring lag, snaps back elastically on exit, and presses like an anvil strike: sharp compression, slow spring recovery, hairline white flash at the base edge.

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

## Install

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

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

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

## Props (`AnvilProps`)

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `strength?` | `number` | `0.8` | How hard the iron leans toward the cursor. |
| `maxDistance?` | `number` | `100` | Radius in px around the button's center within which the pull engages. |
| `spring?` | `AnvilSpringConfig` | — | Magnetic spring. Deliberately heavy defaults — a slab of iron, not a balloon. |
| `flashColor?` | `string` | `white` | Color of the hairline flash at the base edge on strike. |
| `children?` | `React.ReactNode` | — | Button label / content. |
| `ref?` | `React.Ref<AnvilHandle>` | — | Imperative handle — see {@link AnvilHandle}. |

Also accepts: `Omit<HTMLMotionProps<"button">, "children" | "ref">`.

## Usage example

```tsx
import { Anvil } from "@/components/crucible/anvil";

const LABEL = "text-[10px] font-medium uppercase tracking-[0.2em] text-neutral-600";

export default function AnvilDemo() {
  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
        aria-hidden
        className="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.035),transparent_70%)]"
      />
      <div className="relative z-10 flex flex-col items-center gap-10">
        <div className="flex flex-wrap items-end justify-center gap-10">
          <div className="flex flex-col items-center gap-3">
            <Anvil>Click me</Anvil>
            <span className={LABEL}>Default</span>
          </div>
          <div className="flex flex-col items-center gap-3">
            <Anvil strength={1.1} flashColor="#a78bfa">
              Get started
            </Anvil>
            <span className={LABEL}>Custom colors · stronger pull</span>
          </div>
        </div>
        <p className="text-sm text-neutral-500">
          Move your cursor close — the button leans in. Click or press Enter 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.
