React toggle switch component
npm install react-input-switch




React toggle switch component
``sh`
npm install react-input-switch --save
yarn add react-input-switch
https://swiftcarrot.dev/react-input-switch/
`javascript`
track: {
backgroundColor: 'blue'
},
trackChecked: {
backgroundColor: 'red'
},
button: {
backgroundColor: 'yellow'
},
buttonChecked: {
backgroundColor: 'blue'
}
}}
/>
`javascript
import React, { useState } from 'react';
import Switch from 'react-input-switch';
const App = () => {
const [value, setValue] = useState(0);
return
};
`
The default on/off value is 1/0 and default value is 1. This component will also render a hidden input () with current value and the name prop.
`javascript
import React, { useState } from 'react';
import Switch from 'react-input-switch';
const App = () => {
const [value, setValue] = useState('yes');
return
};
``
MIT