Skip to Content
Archi-ui 1.0.25 is released 🎉

Switch

Switchs toggle the state of a single setting on or off

Basic Switch

Usage

import { Switch } from 'archi-ui'
<Switch />

Default Checked

use the defaultChecked prop to Switch checked by default.

Variants

The Switch comes with two variants: rounded(default), standard.

Size

Use size prop to change the size of the switch.

Color

Use color prop to apply different colors for component.

Controlled

You can control the switch with the checked and onChange prop.

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.

Switch API

API reference docs for the React Switch component.

Props

NameTypeDefaultDescription
checkedbool-If true, the component is checked.
defaultCheckedbool-The default checked state. Use when the component is not Controlled.
classNamestring-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.
disabledboolfalseIf true, the component is disabled.
iconnode-The icon to display when the component is unchecked.
checkedIconnode-The icon to display when the component is checked.
onChangefunc-Callback fired when the state is changed. function(event: React.changeEvent) => void. You can pull out the new checked state by accessing event.target.checked (boolean).
requiredboolfalseIf true, the input element is required.
valueany-The value of the component. The DOM API casts this to a string. the browser uses “on” as the default value.
Last updated on