# Refrigerator

A cabinet whose doors are solved leaves on vertical hinges, with an interior that is a second drawing revealed by the swing and a lamp thrown by a real door switch.

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

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

## Notes

- A leaf is a flat panel at an attitude: `swingPose` puts its free edge on a circle about the hinge so the door keeps its width at every angle, and `panelTransform` carries the handle and the display on the leaf, foreshortening as it opens and disappearing when it is edge-on.
- The door is a slab, not a sheet — the same face again along its own normal — which is what gives it an edge from any camera but square on.
- The lamp is a real door switch: it makes at a stated opening, so the inside lights when the seal breaks. The interior is only drawn once a door is open far enough to see past the leaf, which is also why it costs nothing when the cabinet is shut.
- No thermodynamics. The compressor's duty cycle is a pattern on the clock, the display is a label, and nothing computes a heat load, a defrost or a door-open penalty.
- A generic two-door cabinet. No manufacturer, model, badge or livery is reproduced here or in the demo.

## Usage

```tsx
import { Refrigerator } from "@/components/ui/refrigerator"

<Refrigerator behavior="service" layout="top-freezer" />

// Or open it yourself, either compartment.
<Refrigerator door={0.7} freezer={0} view="iso" />
<Refrigerator interactive layout="side-by-side" onDoorChange={setDoor} />
```

## Props

| name | type | default | description |
| --- | --- | --- | --- |
| `view` | `"plan" | "front" | "profile" | "iso"` | `"front"` | Where the camera stands. One cabinet, four projections: straight down, straight on, side elevation, or three-quarter from above. |
| `door` | `number` | — | Controlled fresh-food door, 0 shut to 1 at its 110° stop. Supplying it stops the loop. |
| `freezer` | `number` | — | Controlled freezer door, independent of the fresh one. |
| `behavior` | `"service" | "idle" | "static"` | `"service"` | Open the fresh door, stand open, shut it, then do the same for the freezer — never both at once. Idle keeps it shut and cycles the compressor. |
| `layout` | `"top-freezer" | "side-by-side" | "single"` | `"top-freezer"` | Which leaves the cabinet has, how wide each is and where it is hinged. |
| `shelves` | `number` | `3` | Shelves in the fresh compartment, 2–5, spaced across whatever height that compartment has. |
| `showPlant` | `boolean` | `true` | Draw the condenser coil and the compressor at the back. |
| `speed` | `number` | `0.18` | Service cycles 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 across to swing the fresh door, or arrow-key it. |
| `onDoorChange` | `(door: number) => void` | — | Fresh door opening throughout a drag or a key press. |
| `showGround` | `boolean` | `true` | Draw the contact shadow under the cabinet. |
| `label` | `string` | — | Caption under the drawing. |
| `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/refrigerator.tsx`
