# Snake

A serpentine crawler from above. One travelling wave gives it serpentine travel, sidewinding with half the body lifted clear, or a resting coil.

> For the complete index, see [llms.txt](https://robocn.dev/llms.txt). A Markdown version of any page is available by appending `.md` to its URL or by sending an `Accept: text/markdown` header.

## Install

```bash
bunx --bun shadcn@latest add https://robocn.dev/r/robot-snake.json
```

Registry item: `robot-snake` · [`https://robocn.dev/r/robot-snake.json`](https://robocn.dev/r/robot-snake.json)

## Notes

- Plan view is the identity projection. The spine solver reports a clearance for every joint, so sidewinding is genuinely off the ground rather than shaded to look it — from the side the lifted half of the body is visibly clear of it.
- Lifted sections draw an offset shadow and drop out of the contact marks, so sidewinding reads as height rather than as a differently shaped wave.
- The solver integrates a tangent angle instead of moving joints, so every link is exactly the same length at every phase, turn and amplitude.

## Usage

```tsx
import { RobotSnake } from "@/components/ui/robot-snake"

<RobotSnake behavior="sidewind" showContacts />

// Or scrub the wave yourself.
<RobotSnake phase={0.4} amplitude={0.9} waves={1.5} lift={1} turn={-0.2} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"plan"` | Where the camera stands. One crawler, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `behavior` | `"serpentine" | "sidewind" | "coil" | "static"` | `"serpentine"` | What it does when phase is not supplied: an even wave, alternating sections lifted clear, or curled up and breathing. |
| `phase` | `number` | — | Controlled cycle fraction. Supplying it stops the internal clock. Wraps in both directions. |
| `speed` | `number` | `0.6` | Wave cycles per second. |
| `offset` | `number` | `0` | Seconds of offset, so a nest of them breaks step. |
| `animate` | `boolean` | `true` | Off parks the machine at phase and stops rendering. A reduced-motion preference does the same. |
| `paused` | `boolean` | `false` | Freeze where it stands. |
| `amplitude` | `number` | `0.78` | Peak body swing, clamped to 0–1. Omit and the behavior sets it. |
| `waves` | `number` | `1.5` | Wave crests along the body, clamped to 0.25–3. |
| `turn` | `number` | — | Steady curvature, −1..1, added to the wave. Omit and the head follows the pointer. |
| `lift` | `number` | — | Peak ground clearance on the lifted half of the wave, 0–1. Sidewinding is 1. |
| `segments` | `number` | `16` | Links in the body, rounded and clamped to 3–24. |
| `interactive` | `boolean` | `true` | The head turns toward the pointer, and a click throws a strike that flattens the wave and recovers. |
| `onStrike` | `() => void` | — | Fired on the click that starts a strike. |
| `showGround` | `boolean` | `true` | Ground reference lines under the machine. |
| `showContacts` | `boolean` | `false` | Mark the segments carrying weight. |
| `label` | `string` | — | Caption underneath the snake. |
| `variant` | `"solid" | "outline" | "blueprint" | "wire"` | `"solid"` | How the machine is painted. Geometry never changes between variants. |
| `size` | `"xs" | "sm" | "md" | "lg" | "xl" | number` | `"md"` | Rendered width in pixels, or a step on the scale. |
| `color` | `string` | `var(--robot-shell)` | Body panels — the colour the machine reads as. |
| `accent` | `string` | `var(--robot-accent)` | Status colour: tip light, live tool, readouts. |
| `metal` | `string` | `var(--robot-metal)` | Bare machined parts: collars, bolts, tool bodies. |
| `dark` | `string` | `var(--robot-dark)` | Cast joints, base, shadow side. |
| `palette` | `Partial<RobotPalette>` | — | Override any subset of roles at once, including glow and grid. |

## Source

- `src/components/ui/robot-snake.tsx`
