JavaScripting

The definitive source of the best
JavaScript libraries, frameworks, and plugins.


  • ×

    Bootstrap Switch

    unofficial bootstrap switch
    Filed under 

    • 🔾74%Overall
    • 5,001
    • 14.9 days
    • 🕩1425
    • 👥18

    Bootstrap Switch

    Dependency Status devDependency Status NPM Version

    Turn checkboxes and radio buttons into toggle switches. Created by Mattia Larentis, maintained by Emanuele Marchi and Peter Stein with the help of the community. Compatible with Bootstrap 4, Bootstrap 3 and Bootstrap 2.

    Play with demo on my fiddle.

    Quick start

    Several quick start options are available:

    • Download the latest release
    • Clone the repo: git clone https://github.com/Bttstrp/bootstrap-switch.git
    • Install with npm: npm install bootstrap-switch
    • Install with yarn: yarn add bootstrap-switch
    • Install with Composer: composer require components/bootstrap-switch
    • Install with Bower: bower install bootstrap-switch
    • Install with NuGet: PM> Install-Package Bootstrap.Switch (NuGet package)

    Include the dependencies: jQuery, Bootstrap and Bootstrap Switch CSS + Javascript:

    <link href="bootstrap.css" rel="stylesheet">
    <link href="bootstrap-switch.css" rel="stylesheet">
    <script src="jquery.js"></script>
    <script src="bootstrap-switch.js"></script>
    

    Add your checkbox:

    <input type="checkbox" name="my-checkbox" checked>
    

    Initialize Bootstrap Switch on it:

    $("[name='my-checkbox']").bootstrapSwitch();
    

    Enjoy.

    Supported browsers

    IE9+ and all the other modern browsers.

    LESS

    • For Bootstrap 2 (no longer officially supported), import src/less/bootstrap2/bootstrap-switch.less
    • For Bootstrap 3, import src/less/bootstrap3/bootstrap-switch.less

    SASS/SCSS

    • For Bootstrap 4, import src/sass/bootstrap4/bootstrap-switch.scss

    Bugs and feature requests

    Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

    The new issue should contain both a summary of the issue and the browser/OS environment in which it occurs and a link to the playground you prefer with the reduced test case. If suitable, include the steps required to reproduce the bug.

    Please do not use the issue tracker for personal support requests: Stack Overflow is a better place to get help.

    Known issues

    • Make sure .form-control is not applied to the input. Bootstrap does not support that, refer to Checkboxes and radios

    Integrations

    License

    Licensed under the MIT License.

    Show All