# Duck

A bipedal duck robot: two solved legs on a controlled footfall cycle, a servo-stack neck that cranes and pecks, and a beak that opens.

> 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/micro-duck.json
```

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

## Notes

- Side elevation is the drawing it always had, with the far leg slid sideways to fake its depth. Off that axis both legs stand either side of the pelvis, and the body, neck and head are solids.
- Supplying phase hands the cycle back to your timeline and stops the internal clock — controlled always wins. Without it the duck runs its own, parked by a reduced-motion preference.
- Legs solve two-link inverse kinematics with the knee breaking rearward, and the neck is a three-link FABRIK chain. The drawing preserves link lengths but does not model balance or ground forces.
- The far leg is drawn behind the body at reduced opacity, which is depth in the illustration rather than a second solve.

## Usage

```tsx
import { MicroDuck } from "@/components/ui/micro-duck"

<MicroDuck behavior="walk" />

// Or drive the cycle yourself, the way it has always worked.
<MicroDuck gait="walk" phase={0.3} gaze={0.4} beak={0.2} showContacts />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"profile"` | Where the camera stands. One duck, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `behavior` | `"walk" | "idle" | "peck" | "static"` | `"idle"` | What it does when phase is not supplied: pace, shift its weight and look around, or work the floor. |
| `gait` | `"stand" | "walk" | "strut"` | — | Footfall pattern. Omit and the behavior picks one — walking walks, everything else stands. |
| `phase` | `number` | — | Controlled cycle fraction. Supplying it stops the internal clock. Wraps in both directions; ignored when standing. |
| `speed` | `number` | `0.7` | Gait cycles per second. |
| `offset` | `number` | `0` | Seconds of offset, so a row of ducks breaks step. Phase is the gait cycle here, so the offset has its own name. |
| `interactive` | `boolean` | `true` | Watch the pointer, and quack when poked: a beak snap and a head bob that decay out. |
| `onQuack` | `() => void` | — | Fired on the poke that starts a quack. |
| `height` | `number` | `0.55` | Normalized pelvis height, clamped to 0–1 (24–54 world units). Zero folds the legs into a sit. |
| `stride` | `number` | `0.6` | Normalized fore/aft foot travel, clamped to 0–1. Zero steps in place. |
| `lift` | `number` | `0.5` | Normalized foot clearance, clamped to 0–1. Zero slides the foot along the ground. |
| `gaze` | `number` | — | Neck aim, clamped to −1..1: −1 pecks at the floor, 1 cranes upward. Omit and it follows the pointer, or the behavior. |
| `beak` | `number` | — | Normalized beak opening, clamped to 0–1. One is a 34° gape, and the skull lifts a little with it. Omit and the behavior works it. |
| `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. |
| `showGround` | `boolean` | `true` | Ground reference line; blueprint adds its hatching. |
| `showContacts` | `boolean` | `false` | Mark the foot that is carrying weight. |
| `showCable` | `boolean` | `true` | The wire loom running down the back of the neck. |
| `label` | `string` | — | Caption underneath the robot. |
| `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/micro-duck.tsx`
