Socket
Socket
Sign inDemoInstall

react-bootstrap-switch

Package Overview
Dependencies
21
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-bootstrap-switch

Turn checkboxes and radio buttons into toggle switches.


Version published
Weekly downloads
6.7K
increased by3.49%
Maintainers
1
Install size
1.50 MB
Created
Weekly downloads
 

Readme

Source

Bootstrap Switch

Dependency Status devDependency Status NPM Version

This project is a port of bootstrap-switch for use in React.js

Compatability

Verion 3.4.x is built for React.js 0.14. It will not work with earlier versions of React.js.

NOTE: The CSS from the original version is not fully compatible. There is CSS and LESS included in this repo, or any 3rd party themes can likely be made compatible with the changes shown in this commit.

Usage

Installation

npm install react-bootstrap-switch

Then

var Switch = require('react-bootstrap-switch');

...

render: function() {
  return <Switch />;
}

API

Properties

These should be defined on the JSX node, many cannot be changed once they have been set without recreating the node.

NameTypeDefaultValuesDescription
statebooleantruetrue, falseInitial starting state of the switch
sizestringnullnull, 'mini', 'small', 'normal', 'large'The checkbox size
animatebooleantruetrue, falseAnimate the switch
disabledbooleanfalsetrue, falseDisable state
readonlybooleanfalsetrue, falseReadonly state
indeterminatebooleanfalsetrue, falseIndeterminate state
inversebooleanfalsetrue, falseInverse switch direction
onColorstring'primary''primary', 'info', 'success', 'warning', 'danger', 'default'Color of the on state of the switch
offColorstring'default''primary', 'info', 'success', 'warning', 'danger', 'default'Color of the off state of the switch
onTextstring'ON'Text of the on state of the switch
offTextstring'OFF'Text of the off state of the switch
labelTextstring''Text of the center handle of the switch
handleWidthstring or number'auto''auto' or NumberWidth of the left and right sides in pixels
labelWidthstring or number'auto''auto' or NumberWidth of the center handle in pixels
baseClassstring'bootstrap-switch'Global class prefix
wrapperClassstring'wrapper'Container element class(es)
onChangefunctionundefinedfunction(elm, state){} or function(state){}

Methods

NameParametersDescription
valuebooleanGet or set the switch state
valueStatebooleanGet or set the switch state
toggleValueToggle the switch state
toggleStateToggle the switch state
disabledbooleanGet or set the disabled state
toggleDisabledToggle the disabled state
readonlybooleanGet or set the readonly state
toggleReadonlyToggle the readonly state
handleWidthstring or numberSet the width of the left and right sides in pixels
labelWidthstring or numberSet the width of the center handle in pixels

Supported browsers

IE9+ and all the other modern browsers.

LESS

Import src/less/bootstrap2/bootstrap-switch.less for bootstrap 2 or src/less/bootstrap3/bootstrap-switch.less for bootstrap 3 in your compilation stack.

NOTE: The LESS files from the original switch are not fully compatible, updated versions are included in this repo.

License

Licensed under the MIT License

Keywords

FAQs

Last updated on 15 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc