Theme

npm_versionnpm Paragon package page

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 VariableComputed Value










Props API#

FormSwitch Props API
  • children node Required

    Specifies 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

    Determines whether the label should float to the left when the switch is active.

    Defaultfalse
SwitchControl Props API
  • isIndeterminate bool

    Specifies whether input should be rendered in indeterminate state.

    Defaultfalse
  • className string

    Specifies class name to append to the base element.

Usage Insights#

FormSwitch

Project NameParagon VersionInstance Count
frontend-app-account22.10.01
frontend-app-admin-portal21.13.12
frontend-app-course-authoring22.8.12
frontend-app-learner-dashboard22.9.01
frontend-app-learning22.10.01
frontend-app-publisher21.13.11
frontend-app-support-tools21.13.11
prospectus20.46.22

SwitchControl

Project NameParagon VersionInstance Count
frontend-app-course-authoring22.8.11