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
node
RequiredSpecifies contents of the component.
- className
string
Specifies class name to append to the base element.
- labelClassName
string
Specifies class name to append to the label element.
- helperText
node
Specifies helper text to display below the switch.
- floatLabelLeft
bool
DefaultfalseDetermines whether the label should float to the left when the switch is active.
- isIndeterminate
bool
DefaultfalseSpecifies whether input should be rendered in indeterminate state.
- className
string
Specifies class name to append to the base element.
Usage Insights#
FormSwitch
Project Name | Paragon Version | Instance Count | |
---|---|---|---|
frontend-app-account | 22.10.0 | 1 | |
frontend-app-admin-portal | 21.13.1 | 2 | |
frontend-app-course-authoring | 22.8.1 | 2 | |
frontend-app-learner-dashboard | 22.9.0 | 1 | |
frontend-app-learning | 22.10.0 | 1 | |
frontend-app-publisher | 21.13.1 | 1 | |
frontend-app-support-tools | 21.13.1 | 1 | |
prospectus | 20.46.2 | 2 |
SwitchControl
Project Name | Paragon Version | Instance Count | |
---|---|---|---|
frontend-app-course-authoring | 22.8.1 | 1 |