Skip to main content

Function: Switch()

Switch(__namedParameters): Element

Defined in: components/Switch/Switch.tsx:200

A semantic on/off toggle built on React Aria's SwitchField + SwitchButton (the non-deprecated pair since RAC 1.19).

Entity = Selection → reads vars.colors.input.primary.*, radii: round (pill track + circular thumb), border: outline.control, sizing: hit, motion: feedback.

Validation is the invalid State, never an Evaluation: a switch that must be ON to proceed (isRequired inside a Form, or a validate callback) blocks the submit and reports why through errorMessage.

Parameters

ParameterType
__namedParametersSwitchProps

Returns

Element

Example

<Switch>Enable notifications</Switch>
<Switch defaultSelected>Dark mode</Switch>
<Switch isRequired errorMessage="Confirm before continuing.">
I understand this deletes the workspace
</Switch>