Skip to Content
Puzzle

Switch

Toggle a setting on or off.

Import

import { Switch } from "@puzzle-ui/ui";

Usage and sizes

Use a switch for an immediate binary setting. The label should name the setting rather than describe the action.

390 × 350

API

PropTypeDefaultDescription
labelReactNode-Visible setting name.
descriptionReactNode-Associated supporting text.
size"sm" | "md""md"Visual size.
checkedboolean-Controlled on/off state.
defaultCheckedboolean-Initial uncontrolled state.
onChangeChangeEventHandler<HTMLInputElement>-Read state from event.target.checked.
disabled, requiredbooleanfalseNative input behavior.
classNamestring-Class on the wrapping label.

Standard input attributes such as name, value, and aria-label are supported. The input has role="switch"; Space toggles it. Supply an accessible name when omitting the label.

;