# Servo motor

A positional servo with mounting tabs, a cable, and interchangeable single, double, or cross horns. Drive the shaft angle from application state.

> 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/servo-motor.json
```

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

## Notes

- Front elevation is the drawing it always had. The can, the mounting tabs and the output boss have a depth through the machine that only reads once the camera comes round.
- A supplied angle always wins and stops the loop. The step behavior deliberately jumps its goal: the 210°/s slew rate is what draws the travel between positions, and what carries a released horn back into the sweep.
- The drawing's travel limits are illustrative and do not specify the limits of a particular physical servo.

## Usage

```tsx
import { ServoMotor } from "@/components/ui/servo-motor"

<ServoMotor behavior="step" horn="cross" variant="blueprint" />

// Controlled, or a dial you can turn:
<ServoMotor angle={45} />
<ServoMotor interactive onAngleChange={setAngle} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"front"` | Where the camera stands. One servo, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `angle` | `number` | — | Clockwise horn angle in degrees, clamped to −180..180. Zero points up. Omit it and the shaft runs behavior. |
| `behavior` | `"sweep" | "step" | "hunt" | "static"` | `"sweep"` | Sweep its travel, index between positions, or hunt a degree or two around zero the way a loaded servo does. |
| `speed` | `number` | `0.25` | Sweeps, or passes through the step positions, per second. |
| `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. |
| `phase` | `number` | `0` | Seconds of offset, so a row of machines breaks step. |
| `interactive` | `boolean` | `false` | Drag anywhere around the hub to aim the horn; arrows step 5°, with shift 15°. |
| `onAngleChange` | `(angle: number) => void` | — | Fired throughout a drag or a key press, in controlled mode too. |
| `horn` | `"single" | "double" | "cross"` | `"double"` | One, two, or four attachment arms. The first arm carries the direction mark. |
| `showCable` | `boolean` | `true` | Draw the three-wire cable and connector. |
| `showScale` | `boolean` | `true` | Circular reference scale around the shaft. |
| `label` | `string` | — | Caption under the motor. |
| `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/servo-motor.tsx`
