Pho Design System

Switch

An on/off control for a setting that takes effect immediately — no submit required. Built on Base UI Switch, carrying the switch role and aria-checked. For a value confirmed later on a form, use Checkbox.

Import

import { Switch } from "@photon-ai/pho-ui/components/switch";

Sizes

Two sizes — sm and md (default). A switch is intentionally compact; there is no lg.

<Switch aria-label="Wi-Fi" size="sm" defaultChecked />
<Switch aria-label="Wi-Fi" defaultChecked />

States

Control with checked / onCheckedChange, or leave it uncontrolled with defaultChecked. disabled dims and blocks interaction.

<Switch aria-label="Notifications" defaultChecked />
<Switch aria-label="Notifications" />
<Switch aria-label="Notifications" defaultChecked disabled />

With a label

A lone switch is ambiguous. Give it a visible <label> and tie the two together with id / htmlFor — clicking the label then toggles the control. This is also the shape of a controlled switch, driving checked from state via onCheckedChange.

Join known networks automatically.

const [checked, setChecked] = useState(true);

<label htmlFor="wifi">Wi-Fi</label>
<Switch id="wifi" checked={checked} onCheckedChange={setChecked} />

Props

Accessibility

Keyboard:

disabled removes the switch from the tab order; readOnly keeps it focusable but rejects the toggle.

Best practices