Switch
Switchs toggle the state of a single setting on or off
Basic Switch
Preview
Usage
import { Switch } from 'archi-ui'<Switch />Default Checked
use the defaultChecked prop to Switch checked by default.
Preview
Variants
The Switch comes with two variants: rounded(default), standard.
Preview
Size
Use size prop to change the size of the switch.
Preview
Color
Use color prop to apply different colors for component.
Preview
Controlled
You can control the switch with the checked and onChange prop.
Preview
Switch is checked: true
Icon
You can also add icon to switch using icon prop, and you can also modifie the icon for checked using checkedIcon.
Preview
Switch API
API reference docs for the React Switch component.
Props
| Name | Type | Default | Description | 
|---|---|---|---|
| checked | bool | - | If true, the component is checked. | 
| defaultChecked | bool | - | The default checked state. Use when the component is not Controlled. | 
| className | string | - | Override or extend the styles applied to the component | 
| variant | 'rounded' | 'standard' | 'rounded' | The variant to use. | 
| size | 'sm' | 'md' | 'md' | The size of the component. | 
| color | 'default' | 'primary' | 'secondary' | 'info' | 'warning' | 'success' | 'error' | 'primary' | The color of the component. | 
| disabled | bool | false | If true, the component is disabled. | 
| icon | node | - | The icon to display when the component is unchecked. | 
| checkedIcon | node | - | The icon to display when the component is checked. | 
| onChange | func | - | Callback fired when the state is changed. function(event: React.changeEvent) => void. You can pull out the new checked state by accessingevent.target.checked(boolean). | 
| required | bool | false | If true, theinputelement is required. | 
| value | any | - | The value of the component. The DOM API casts this to a string. the browser uses “on” as the default value. | 
Last updated on