# Solenoid valve

A helical coil pulls a sprung plunger across a two- or three-port valve gallery. The plunger, spring and visible flow route all answer the same controlled position.

> 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/solenoid-valve.json
```

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

## Notes

- The winding is sampled as a fixed-envelope helix. Flow switching and field loops are explanatory geometry; no fluid force, pressure, coil heating or magnetic flux density is calculated.

## Usage

```tsx
import { SolenoidValve } from "@/components/ui/solenoid-valve"

<SolenoidValve behavior="pulse" ports={3} normally="closed" view="iso" />
<SolenoidValve position={0.7} interactive onPositionChange={setPosition} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `position` | `number` | — | Controlled plunger stroke from 0 released to 1 pulled. |
| `behavior` | `"cycle" | "pulse" | "static"` | `"cycle"` | Automatic plunger duty cycle when position is omitted. |
| `ports` | `2 | 3` | `2` | Number of visible valve ports. |
| `normally` | `"open" | "closed"` | `"closed"` | Whether the released flow route is open or closed. |
| `interactive` | `boolean` | `false` | Drag or arrow-key the plunger. |
| `onPositionChange` | `(position: number) => void` | — | Reports pointer and keyboard changes. |
| `showField` | `boolean` | `true` | Show qualitative activation loops around the coil. |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"profile"` | Where the camera stands. One solenoid valve, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `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. |
| `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/solenoid-valve.tsx`
