2.2.2 • Published 5 years ago
react-input-switch v2.2.2
react-input-switch
React toggle switch component
Installation
npm install react-input-switch --save
yarn add react-input-switch
Demo
https://swiftcarrot.dev/react-input-switch/
Custom styles
<Switch
styles={{
track: {
backgroundColor: 'blue'
},
trackChecked: {
backgroundColor: 'red'
},
button: {
backgroundColor: 'yellow'
},
buttonChecked: {
backgroundColor: 'blue'
}
}}
/>
Controlled example (with hook)
import React, { useState } from 'react';
import Switch from 'react-input-switch';
const App = () => {
const [value, setValue] = useState(0);
return <Switch value={value} onChange={setValue} />;
};
Custom on/off value
The default on/off value is 1/0 and default value is 1. This component will also render a hidden input (<input type="hidden"/>
) with current value and the name prop.
import React, { useState } from 'react';
import Switch from 'react-input-switch';
const App = () => {
const [value, setValue] = useState('yes');
return <Switch on="yes" off="no" value={value} onChange={setValue} />;
};
License
MIT
2.2.2
5 years ago
2.2.1
6 years ago
2.2.0
6 years ago
2.1.31
6 years ago
2.1.30
6 years ago
2.1.29
6 years ago
2.1.28
6 years ago
2.1.27
6 years ago
2.1.25
6 years ago
2.1.24
6 years ago
2.1.23
6 years ago
2.1.22
6 years ago
2.1.21
6 years ago
2.1.19
6 years ago
2.1.18
6 years ago
2.1.17
6 years ago
2.1.16
6 years ago
2.1.15
6 years ago
2.1.14
6 years ago
2.1.13
6 years ago
2.1.12
6 years ago
2.1.11
6 years ago
2.1.10
6 years ago
2.1.9
6 years ago
2.1.8
6 years ago
2.1.6
6 years ago
2.1.5
6 years ago
2.1.4
6 years ago
2.1.3
6 years ago
2.1.2
7 years ago
2.1.1
7 years ago
2.1.0
7 years ago
2.0.4-alpha.0
7 years ago
2.0.3-alpha.0
7 years ago
2.0.2-alpha.0
7 years ago
2.0.1-alpha.0
7 years ago
2.0.0-alpha.0
7 years ago
1.2.1
9 years ago
1.2.0
9 years ago
1.1.0
10 years ago
1.0.1
10 years ago
1.0.0
10 years ago