|
1 | | -# bootstrap-switch-button-react |
2 | | -Bootstrap Switch Button for React |
| 1 | +[](https://github.com/gitbrent/bootstrap-switch-button-react/blob/master/LICENSE) |
| 2 | + |
| 3 | +# Bootstrap Switch Button for React |
| 4 | + |
| 5 | +Checkbox replacement using stylish bootstrap-4 switch button. |
| 6 | + |
| 7 | +Lightweight, pure JavaScript, no dependencies. |
| 8 | + |
| 9 | +## Installation |
| 10 | +```bash |
| 11 | +npm i bootstrap-switch-button-react --savedev |
| 12 | +``` |
| 13 | + |
| 14 | +## Demo |
| 15 | +```typescript |
| 16 | +import BootstrapSwitchButton from 'bootstrap-switch-button-react' |
| 17 | + |
| 18 | +<BootstrapSwitchButton |
| 19 | + checked={false} |
| 20 | + onlabel='Admin User' |
| 21 | + offlabel='Normal User' |
| 22 | + onChange={(checked: boolean) => { |
| 23 | + this.setState({ isUserAdmin: checked }) |
| 24 | + }} |
| 25 | +/> |
| 26 | +``` |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +## Options |
| 31 | + |
| 32 | +Name |Type |Default |Description | |
| 33 | +----------|-----------|----------|----------------------------| |
| 34 | +`on` |string/html|"On" |Text of the on toggle |
| 35 | +`off` |string/html|"Off" |Text of the off toggle |
| 36 | +`size` |string |"normal" |Size of the toggle. Possible values are: `large`, `normal`, `small`, `mini`. |
| 37 | +`onstyle` |string |"primary" |Style of the on toggle. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark` |
| 38 | +`offstyle`|string |"light" |Style of the off toggle. Possible values are: `primary`,`secondary`,`success`,`danger`,`warning`,`info`,`light`,`dark` |
| 39 | +`style` |string | |Appends the value to the class attribute of the toggle. This can be used to apply custom styles. Refer to Custom Styles for reference. |
| 40 | +`width` |integer |*null* |Sets the width of the toggle. if set to *null*, width will be auto-calculated. |
| 41 | +`height` |integer |*null* |Sets the height of the toggle. if set to *null*, height will be auto-calculated. |
| 42 | + |
| 43 | +## Methods |
| 44 | + |
| 45 | +Method |Description |
| 46 | +-----------|------------------------------------------ |
| 47 | +on |Sets the toggle to 'On' state |
| 48 | +off |Sets the toggle to 'Off' state |
| 49 | +toggle |Toggles the state of the toggle on/off |
| 50 | +enable |Enables the toggle |
| 51 | +disable |Disables the toggle |
0 commit comments