Switch
What is this?
Switch is a component for customizing configurations. It represents a physical switch that allows users to turn things on or off, providing control over actions and preferences. Tapping a toggle switch is a two-step action: selection and execution. It should reflect an action that triggers a state, never both at once.
Examples
Standalone
When using a standalone Switch
you should provide an aria-label
property value. As a form
component, it should have a label specified to guarantee accessibility.
With help text
With error text
With help and error texts
Disabled
Checked States
There are two checked states: `checked`, and `not checked`.
Multiple Switches
Oftentimes we need to render multiple switches and store the checked values in an array. It can be easily done using our `useSwitchState` hook, you just need to pass the hook return object to the switches `state` property and define a `value` for each `Switch`.
TypeError: Cannot read properties of undefined (reading 'join')