# Arming switch

> An aircraft style guarded switch for dangerous actions such as a production deploy. Lift the translucent red cover on its hinge, throw the chrome bat toggle until it snaps over center and the lamp flickers on, then press and hold the lamp to run the action. Closing the cover throws an armed switch back to safe.

- Type: Component (special)
- Access: Arc Pro
- Page: https://uiarc.dev/components/arming-switch
- Markdown: https://uiarc.dev/components/arming-switch/markdown
- Source file: `registry/components/arming-switch/arming-switch.tsx`
- Dependencies: lucide-react
- Keywords: special, switch, toggle, confirm, destructive, deploy, danger zone, hold, metal, 3d, physics, new, guarded switch, safety cover, toggle switch, arm, arming, dangerous action, destructive action, production deploy, delete, hold to confirm, aircraft, cockpit, missile switch, brushed aluminium, chrome, lamp

## When to use

- Confirming a production deploy, a data deletion or another action that should never fire by accident.
- A danger zone in settings where one guarded control carries the whole decision, with room for a showpiece.
- A product page or launch moment that shows how seriously your tool treats destructive actions.

## When not to use

- Use hold-to-confirm or slide-to-confirm for a quick deliberate confirmation in a dense list or a toolbar.
- Use a dialog that asks people to type the resource name when they must prove they know exactly what they are deleting.
- Use switch for an ordinary setting that is safe to flip back and forth.

## Installation

Arming switch is part of Arc Pro. The live preview is public; the source and install command need Pro.

### CLI with a Pro token

1. Create a token in your account and set it in the environment (or `.env.local`). Never commit it.

```bash
export ARC_PRO_TOKEN=arc_pro_...
```

2. Add the Pro registry to `components.json`:

```json
{
  "registries": {
    "@uiarc": "https://uiarc.dev/r/{name}.json",
    "@uiarc-pro": {
      "url": "https://uiarc.dev/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${ARC_PRO_TOKEN}"
      }
    }
  }
}
```

3. Install:

```bash
npx shadcn@latest add @uiarc-pro/arming-switch
```

### Manual

Signed-in Pro members can copy the source from the Manual tab on the docs page.

- Plans: https://uiarc.dev/pricing
- Create a Pro token: https://uiarc.dev/account#pro-access
- Setup guide: https://uiarc.dev/docs/ai#pro-access

## Usage

```tsx
import { ArmingSwitch } from "@/components/arc/arming-switch/arming-switch";

export function DeleteWorkspace({ workspace }: { workspace: Workspace }) {
  return (
    <ArmingSwitch
      title="Delete workspace"
      description={`${workspace.name}, ${workspace.members} members and ${workspace.projects} projects`}
      holdLabel="Hold to delete"
      statusLabels={{ running: "Deleting", done: "Deleted" }}
      hints={{
        armed: "Press and hold the lamp to delete the workspace.",
        running: "Removing projects and members.",
        done: "Workspace deleted. This cannot be undone.",
        failed: "Nothing was deleted. Hold the lamp to retry.",
      }}
      holdDuration={1800}
      onConfirm={async () => {
        const result = await api.deleteWorkspace(workspace.id);
        return result.ok;
      }}
    />
  );
}
```

## API reference

### ArmingSwitch

An aircraft style guarded switch for a dangerous action, such as a production deploy, deleting a workspace or rotating a key. The switch sits on a brushed aluminium plate with engraved markings and hex socket screws, under a translucent red safety cover. Lift the cover on its hinge, throw the chrome bat toggle up until it snaps over center and the lamp flickers on, then press and hold the lamp until the ring fills to run the action. Success lights the lamp green with a glint across the plate, then the cover falls shut and pushes the switch back to safe. Closing the cover at any time safes an armed switch, like the real thing.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` | `"Deploy to production"` | Heading of the card, naming the action. |
| `description` | `string` | `"api-gateway v2.14.0 to eu-west-1 and us-east-1"` | One line under the heading saying what runs and where. Pass an empty string to hide it. |
| `armLabel` | `string` | `"Arm"` | Engraved beside the up position of the toggle. Also names the switch for assistive technology, as Arm switch. |
| `safeLabel` | `string` | `"Safe"` | Engraved beside the down position of the toggle. |
| `holdLabel` | `string` | `"Hold to deploy"` | Engraved under the lamp, and the accessible name of the lamp button. |
| `readyLabel` | `string` | `"Ready"` | Engraved beside the small ready light, which beats while idle, flickers while the action runs and stays lit once it is done. |
| `statusLabels` | `Partial<Record<ArmingSwitchStatus, string>>` | – | Status chip text per state: safe, open, armed, running, done and failed. Defaults read Safe, Cover open, Armed, Deploying, Deployed and Failed; missing keys keep them. |
| `hints` | `Partial<Record<ArmingSwitchStatus, string>>` | – | The next step shown under the panel per state, also announced with each status change. Missing keys keep the defaults. |
| `holdDuration` | `number` | `1200` | How long the lamp must be held, in milliseconds, from 300 to 6000. Letting go early drains the ring; pressing again picks up where it drained to. |
| `onConfirm` | `() => void \| boolean \| Promise<void \| boolean>` | – | Runs when the hold completes. Return nothing or true for success. Return or resolve false, or throw or reject, for the failed state. A promise shows the running state, with the lamp pulsing and the ring spinning, until it settles. |
| `autoSafe` | `boolean` | `true` | After a success, close the cover on its own a moment later, which throws the switch back to safe. The green lamp stays lit until the cover is lifted again. |
| `disabled` | `boolean` | `false` | Locks the cover, the switch and the lamp. Attempts rattle the cover and explain that the switch is locked. |
| `haptics` | `boolean` | `true` | A short vibration on the snap, the cover landing, a knock against the closed cover and the result, on devices that support it. Never before the first touch. |
| `accent` | `string` | – | Any CSS color for the hold ring. Defaults to the accent. |
| `coverColor` | `string` | – | Any CSS color for the translucent cover and the tinted shadow it casts. Defaults to safety red. |
| `onStatusChange` | `(status: "safe" \| "open" \| "armed" \| "running" \| "done" \| "failed") => void` | – | Called whenever the status changes. |
| `onCoverChange` | `(open: boolean) => void` | – | Called when the cover is lifted or closed, including when a drag carries it past halfway. |
| `onArmChange` | `(armed: boolean) => void` | – | Called when the switch snaps to armed or returns to safe, including when a closing cover pushes it back. |
| `label` | `string` | – | Accessible name of the whole component. Defaults to the title. |
| `className` | `string` | – | Class on the root element. |
| `style` | `CSSProperties` | – | Inline styles on the root element. |

## Keyboard interactions

| Keys | Action |
| --- | --- |
| Tab | Moves between the safety cover, the switch and the lamp, in that order. |
| Enter / Space on the cover | Lifts the cover, or closes it. Closing it throws an armed switch back to safe. |
| Arrow Up / Arrow Down on the cover | Lifts or closes the cover. |
| Enter / Space on the switch | Arms the switch or returns it to safe. Under a closed cover the bat knocks the lid and the hint asks to lift the cover first. |
| Arrow Up / Arrow Down on the switch | Arms the switch or returns it to safe. |
| Hold Enter or Space on the lamp | Fills the ring for the hold duration, then runs the action. Releasing early drains the ring. |
| Escape | Makes everything safe: ends a hold, closes the cover and returns the switch to safe. Ignored while the action runs. |

## Accessibility

- The component is a labelled group with a real heading. The cover, the switch and the lamp are real buttons laid over the drawing, so pointer, touch and keyboard reach the same controls.
- The cover button is named Lift safety cover or Close safety cover. The switch is role="switch" named Arm switch with aria-checked, and is aria-disabled while the cover is closed. The lamp is named with holdLabel and is aria-disabled until the switch is armed.
- Every control is described by the next step line under the panel, so each one says what to do. Refusals such as Lift the safety cover first replace that line briefly and are announced.
- Status changes are announced in a polite live region with the status and the next step, for example Armed. Press and hold the lamp to deploy.
- The status never relies on color: the chip pairs an icon with Safe, Cover open, Armed, Deploying, Deployed or Failed, and its width never changes between them.
- The plate, the cover, the bat and the lamp are decorative and hidden from assistive technology; everything they show is in the controls, the chip or the next step.

## Motion

- One requestAnimationFrame loop steps every part as a spring at 240 Hz and writes transforms, opacity and SVG attributes straight to the DOM. React renders only on discrete events such as the cover opening or the switch arming.
- The cover is a real 3D box of translucent faces on a hinge. Dragging keeps its lip under the finger by solving the hinge angle from the pointer, rubber bands past the open stop and keeps the release speed. It is spring loaded into its stops: it snaps up against the open stop with a clack and a small rebound, and falls shut with a thunk, a short hop and a wobble on its hinge. Hovering lifts it a few degrees.
- The bat follows the finger one to one until it passes center, where the over center spring takes it out of your hand and slams it into the stop with a short chatter. Let go before center and it snaps back with the speed of your hand. Under a closed cover it knocks the lid up off its seat instead.
- Light is fixed to the room. The panel leans a few degrees toward the pointer on a soft spring, the grain streak slides across the brushed aluminium, the screw heads and the bat tip catch the light, a reflected horizon slides along the chrome shaft as it tilts, and a glare sweeps down the red lid as it rises. Shadows are projected along the light: the cover's red tinted shadow slides up and thins as it lifts, the bat's shadow swings and shortens.
- Arming lights the lamp like a filament catching, with two quick flickers, a bloom on the lens and a warm spill across the plate, then a slow breath. Holding presses the lens in, fills the ring with a bright leading head and brightens the lamp.
- Completion releases the button, pops a ring off the lamp and nudges the panel. Success crossfades the lamp to green with a second, wider ring and a glint across the plate, then the cover falls shut, catches the bat on the way down and throws it to safe. Failure blinks the lamp red, shakes the panel and drains the red ring.
- Idle, the grain highlight drifts slowly and the ready light beats. On first sight the cover hops once on its hinge. Parts that land give the whole panel a small jolt.
- The loop stops offscreen, in background tabs and whenever everything is at rest; idle drift, the ready light and the lamp's breath are compositor animations that pause offscreen.
- With reduced motion there is no tilt, drift, flicker, bounce or glint: the cover and the switch jump to their new pose and fade in, the lamp and the ring fade, and the hold still fills so the action keeps its safeguard.

## Responsive behavior

- The plate is drawn in its own container units, so the cover, the bat, the lamp, the screws and the engraving keep their proportions from a phone to a desktop card, up to 560px across. Engraving never drops below 9px.
- Above 720px the title, status and next step sit in a column beside the panel. Below that they stack, and below 420px the card tightens its padding.
- The cover, the switch and the lamp capture touch so drags never scroll the page; the rest of the panel leaves vertical scrolling alone. Long presses on the lamp do not open the context menu.
- The stage keeps room above the plate for the flipped cover, so it never covers the heading.

## Performance

- Everything that moves is a transform or opacity on its own layer: the panel, the cover box and its faces, the bat and its tip, the light layers, the lamp blooms, spills and rings. The ring is one small SVG whose dash offset changes.
- Writes go through a cache, so a still frame touches nothing, and the loop idles completely at rest. Pointer math reads one rectangle per press.
- The brushed grain is one tiled SVG noise image rasterized once. There is no canvas and no layout read inside the loop.

## Notes for AI

- Use it for an action that is costly to undo and deserves a deliberate, two step ritual: production deploys, deleting a workspace or a database, rotating a root key, releasing a payout, launching a campaign to every customer.
- It is friction, not authorization. Check permissions on your server inside onConfirm and return false or reject when the action does not go through.
- Keep the title to the action and the description to what it touches, such as the service, the version and the regions. Rename holdLabel, statusLabels and hints together for actions other than a deploy.
- Return a promise from onConfirm so people see the running state; resolve it only when the action has really finished.
- Leave autoSafe on for one shot actions. Turn it off when people may run the action again right away and would rather keep the cover up.

## Related

- [Hold to confirm](https://uiarc.dev/components/hold-to-confirm/markdown): Confirm a destructive action by holding, not tapping.
- [Slide to confirm](https://uiarc.dev/components/slide-to-confirm/markdown): A slide-to-confirm control. The thumb pulls a liquid fill behind it and makes the track swell. It snaps back on a spring if released early. Past the threshold, the track draws into the thumb and the chevron morphs into a success check, with pending and error states.
- [Confirm morph](https://uiarc.dev/components/confirm-morph/markdown): A destructive button that morphs into an inline confirmation, a spinner, and a result with undo.
- [Switch](https://uiarc.dev/components/switch/markdown): A tactile toggle for settings that take effect immediately.

## Also in loaders

- [Stretch refresh](https://uiarc.dev/components/stretch-refresh/markdown): Pull a feed down and a line stretches to tell you when to let go.
- [Feedback morph](https://uiarc.dev/components/feedback-morph/markdown): A feedback button that becomes a form, then a thank-you, in one shape.
- [Morph loader](https://uiarc.dev/components/morph-loader/markdown): Tiny loaders that morph between shapes and fold into a check or a cross when done.
- [Skeleton morph](https://uiarc.dev/components/skeleton-morph/markdown): Loading skeletons that grow into the real content, block by block, instead of swapping.
- [Celebrate button](https://uiarc.dev/components/celebrate-button/markdown): A button that bursts confetti from its own edges on success while the label morphs to done.
- [Black hole](https://uiarc.dev/components/black-hole/markdown): A delete transition that pulls the chosen items into a tiny singularity while the rest of the list bends around it; undo spins them back out.
- [Charge session](https://uiarc.dev/components/charge-session/markdown): An EV or device charging card. Energy packets flow from a charger along the cable into the battery pack, which fills toward a draggable charge limit. The charge curve tapers near full, and power, energy, time to limit and cost update live. Stop charging drains the flow.

## Guidance for AI tools

Arming switch: An aircraft style guarded switch for dangerous actions such as a production deploy. Lift the translucent red cover on its hinge, throw the chrome bat toggle until it snaps over center and the lamp flickers on, then press and hold the lamp to run the action. Closing the cover throws an armed switch back to safe. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://uiarc.dev/llms.txt
