Skip to main content

AmbientSwitch

AmbientSwitch is a slide switch — a pill riding in a recessed stadium track — with an optional LED indicator.

Interactive preview

Power
Record
Small
Large

Grounded counterpart

The switch is modeled on its 3D referent (ambient3d/components/switch.py): a pill sliding in a stadium recess cut into the panel. The track is an .amb-groove; the pill stands the referent's 2.6mm above the recess floor.

Live CSS
switch ground-truth render
Blender ground truth

Props

PropTypeDefaultNotes
valueboolean-Controlled state.
defaultValuebooleanfalseUncontrolled initial state.
onChange(on: boolean) => void-Called when toggled.
size"sm" | "md" | "lg""md"Switch size variant.
labelstring-Optional visible label.
ledboolean | string-true for default green, string for custom color.

Also accepts standard button props (except native onChange).

Examples

Uncontrolled

<AmbientSwitch label="Power" defaultValue />

Controlled

const [enabled, setEnabled] = useState(false);

<AmbientSwitch value={enabled} onChange={setEnabled} label="Bypass" />

Custom LED color

<AmbientSwitch label="Record" led="#ef4444" defaultValue />