@s-ui/react-atom-switch v2.3.0
AtomSwitch
The switch is the radio button when there’re only 2 exclusive options. “On/off” is a common and clear example for explaining this component.
In order to collect the result of this switch there is a callback onToggle, this callback receives a flag on true if select is active. If you're using a select type of this component, false means the first option and true the second one.
There are several two sizes for this component: default and large.
Installation
$ npm install @s-ui/react-atom-switch --saveUsage
Basic usage - Uncontrolled component
import AtomSwitch from '@s-ui/react-atom-switch'
return (
<AtomSwitch
disabled={false}
initialValue={false}
isFitted={false}
isLoading={true}
label="Label"
labelLeft="Off"
labelOptionalText="Optional label"
labelRight="On"
onToggle={flag => console.log(`Switch value is ${flag}`)}
size="default"
type="toggle"
/>
)Basic usage - Controlled component
import AtomSwitch from '@s-ui/react-atom-switch'
return (
<AtomSwitch
labelLeft="Off"
labelRight="On"
onToggle={value => handleChangeFromParent(value)}
type="toggle"
value={value}
/>
)Find full description and more examples in the demo page.
6 months ago
6 months ago
8 months ago
8 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago