ToggleSwitch
Props
name = {string}
- Input name.
options = {object[]}
defaultOption = {object}
onChange = {function}
- Function triggered when the value is changed. Takes two parameters:
value
andevent
which has a propertyname
(input name).
- Function triggered when the value is changed. Takes two parameters:
Example with code
import ToggleSwitch from '@components/ToggleSwitch';
const MyComponent = () => {
const options = [{
label: 'Option 1',
value: 'first',
}, {
label: 'Option 2',
value: 'second',
}, {
label: 'Option 3',
value: 'third',
}];
const handleInputChange = (value, { name }) => {
console.log(name, value);
};
return (
<ToggleSwitch
name="my_switch"
options={options}
onChange={handleInputChange}
/>
);
};