Meridianby Commenda
Components

Switch

A setting that applies the moment it changes.

Turns a setting on or off right away, with its 14 label and optional description built in. Track 36 × 20, a white thumb that slides. On the site it sits in the cookie preferences panel and in product shots of settings.

Analytics cookiesoff
Analytics cookieson

Usage

Example.tsx
import { Switch } from "@commenda/meridian/ui/switch";

<Switch label="Analytics cookies" checked={analytics} onCheckedChange={setAnalytics} />;

Off and on

The change applies at once, with no Save button.

Analytics cookiesoff
Analytics cookieson

In settings

A list of settings, each with a label and a line saying what changes.

Strictly necessary cookiesKeep the site and your forms working. Always on.These cookies are always onAnalytics cookiesHelp us see which pages people read.Marketing cookiesLet us show you relevant Commenda ads elsewhere.

States

Hover darkens the track. Focus is the blue ring with a white gap. Disabled keeps its label readable.

defaultoff · default
disabledLocked by your admindisabled
defaulton · default
disabledLocked by your admindisabled

Hover and Tab to see hover and focus.

Anatomy

Track 36 × 20, radius full: soft-pearl 400 off, blue 700 on. Thumb 16, white with Elevation/control, 2 from the edge; it slides 200 ms ease-out. The label is 14 and sits 8 to the right.

API reference

PropTypeDescription
labelRequiredstringFrom Pathfinder.
hideLabelbooleanFrom Pathfinder.
descriptionstringFrom Pathfinder.
disabledReasonstringFrom Pathfinder.
classNamestringFrom Pathfinder.
onCheckedChange(checked: boolean) => voidFrom Pathfinder.
defaultCheckedbooleanWhether the switch is initially active. To render a controlled switch, use the checked prop instead.
styleCSSProperties | ((state: SwitchRootState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.
formstringIdentifies the form that owns the hidden input. Useful when the switch is rendered outside the form.
disabledbooleanWhether the component should ignore user interaction.
namestringIdentifies the field when a form is submitted.
valuestringThe value submitted with the form when the switch is on. By default, switch submits the "on" value, matching native checkbox behavior.
idstringThe id of the hidden input element. When nativeButton is true, the id is applied to the root element.
readOnlybooleanWhether the user should be unable to activate or deactivate the switch.
requiredbooleanWhether the user must activate the switch before submitting a form.
inputRef((instance: HTMLInputElement | null) => void | (() => VoidOrUndefinedOnly) | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLInputElement | null>A ref to access the hidden <input> element.
checkedbooleanWhether the switch is currently active. To render an uncontrolled switch, use the defaultChecked prop instead.
uncheckedValuestringThe value submitted with the form when the switch is off. By default, unchecked switches do not submit any value, matching native checkbox behavior.

Best practices

  • Use a Switch for a setting that takes effect the moment it changes. In a form that sends later, like a HubSpot form, use a Checkbox.
  • The label names the setting, not the action ("Analytics cookies", not "Turn on analytics"). It never changes between on and off.
  • Show the result straight away. If the change can fail, turn the Switch back and say why.
  • Never use a Switch for a choice between two options that are not on and off. Use Radio or a SegmentedControl, like the monthly and annual pricing toggle.
  • Source: Pathfinder Switch. Meridian sets labels in 14 and descriptions in 14.

On this page