Form.Switch
A switch control for use with Form.SwitchSet. This component has identical
props to Form.Checkbox and is interoperable with Form.SwitchSet and
useCheckboxSetValues.
Note: extra props added to this component are passed as attributes to the
underlying input node. See MDN for documentation on available
input attributes.
Controlled Standalone Usage
Any Paragon component or export may be added to the code example.
Unlabeled control
Any Paragon component or export may be added to the code example.
Controlled Group Usage with useCheckboxSetValues
useCheckboxSetValues(initialValues[]) returns an array: [state, dispatchers].
dispatchers includes add(value) remove(value) set(values[]) and clear()
Any Paragon component or export may be added to the code example.
Uncontrolled Usage
Any Paragon component or export may be added to the code example.
Indeterminate Usage
Any Paragon component or export may be added to the code example.
Inline layout
Any Paragon component or export may be added to the code example.
Label Position
The label is positioned to the right of the switch control by default. The label can be rendered on the left instead
by passing the floatLabelLeft prop.
Any Paragon component or export may be added to the code example.
Helper Text
A helper text component can be passed in to be rendered below the switch control.
Any Paragon component or export may be added to the code example.
Theme Variables#
| CSS Variable | Computed Value |
|---|---|
| | |
| | |
| | |
| | |
| | |
Props API#
- children
nodeRequiredSpecifies contents of the component.
- className
stringSpecifies class name to append to the base element.
- labelClassName
stringSpecifies class name to append to the label element.
- helperText
nodeSpecifies helper text to display below the switch.
- floatLabelLeft
boolDefaultfalseDetermines whether the label should float to the left when the switch is active.
- isIndeterminate
boolDefaultfalseSpecifies whether input should be rendered in indeterminate state.
- className
stringSpecifies class name to append to the base element.
Usage Insights#
FormSwitch
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 20.46.3 | 1 | |
| frontend-app-admin-portal | 20.46.3 | 1 | |
| frontend-app-course-authoring | 21.5.6 | 1 | |
| frontend-app-learner-dashboard | 20.46.2 | 1 | |
| frontend-app-learning | 20.46.0 | 1 | |
| frontend-app-publisher | 20.46.3 | 1 | |
| frontend-lib-content-components | 21.5.6 | 1 | |
| prospectus | 20.46.2 | 2 |
SwitchControl
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-course-authoring | 21.5.6 | 1 |