Switch
Toggles a single setting on or off.
Show codeHide code
Installation
import { Switch } from "@makeplane/propel/components/switch";Usage
import { Switch } from "@makeplane/propel/components/switch";
import * as React from "react";
export default function BasicDemo() {
const [checked, setChecked] = React.useState(true);
return (
<Switch
size="md"
aria-label="Enable notifications"
checked={checked}
onCheckedChange={setChecked}
/>
);
}Examples
Sizes
size sets the track, in the order Figma lists it: lg 30×18, md 27×16, sm 23×14 px. The
thumb derives from the track and is not its own axis. Every track is under WCAG 2.5.8’s 24px
floor, so each size carries a transparent ring that brings the pointer target up to it.
Show codeHide code
States
Switches read as off, on, disabled, or read-only. A disabled on switch dims to 40% opacity; a disabled off switch swaps to a solid muted track instead. Read-only dims either state without blocking the pointer.
Show codeHide code
With description
Automatically restart the service after a crash.
Show codeHide code
Native button
The switch renders as a <span> by default, so the simplest way to label it is wrapping it in a <label> element. When the label needs to be a sibling instead — wired up with htmlFor/id rather than a wrapper — pass nativeButton and a host element via render (typically <button type="button" />). The styled track (and its size) stay on Switch; only the underlying element swaps. The look is unchanged, and clicking the sibling label still toggles the switch.
Show codeHide code
API Reference
Switch
The ready-made switch: grafts Base UI's `Switch` behavior onto the styled `Switch` track and `SwitchThumb` knob. The track owns the required `size`; the thumb sizes itself from it. Base UI supplies `role="switch"` and full keyboard/form support. Maps to Figma's "Toggle" component. On/off, `disabled`, and `readOnly` are control state from the primitive, not variants — pass them as props (`checked`/`defaultChecked`, `disabled`, `readOnly`). Only the size axis (`size`) is a visual variant. When `nativeButton` is set, pass a host element via `render` (typically `<button type="button" />`) — `size` still lives on this component and is applied to the styled track that wraps the host, so callers do not re-specify size on `SwitchTrack`.