Bootstrap Toggle

Bootstrap Toggle

Bootstrap Toggle is a lightweight Bootstrap plugin that allows toggle switches on your pages.

Download Source Code

Getting Started


Requirements

Bootstrap Toggle requires jQuery and Bootstrap.

Download

Download the zip file or visit GitHub page for the source code.

Setup

Include the css and js file on your page.

<link href="http://gitcdn.github.io/ajax/bootstrap-toggle/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="http://gitcdn.github.io/ajax/bootstrap-toggle/js/bootstrap-toggle.min.js"></script>

Examples


Default On

Here's an example of a toggle with default set to On. Make sure that .toggle's classes match .toggle-on's classes.


				

Default Off

Here's an example of a toggle with default set to Off. Make sure that .toggle has a class of .off, and that .toggle's classes match .toggle-off's classes.


				

Toggle Sizes

Bootstrap toggle is available in different sizes. Make sure .toggle, label, and span have the same button size class.


				

Customization


Colors

Bootstrap Toggle supports various colors. Refer to Bootstrap Documentation on color variations. As stated previously, .toggle's classes needs to match the visible label's classes. You can also create your own custom color with css and add it to label of your choice.


				

Color Mix

You can also mix & match different colors for on/off toggles. Refer to Bootstrap Documentation on color variation. As stated previously, .toggle's classes needs to match the visible label's classes. You can also create your own custom color with css and add it to label of your choice.


				

Style

Feel free to style your toggles using css.

	
				

Custom Text

You can also have custom text inside label tag. Unfortunately, the width doesn't scale along with text so you'll need to specify the width of the toggle if you're going have custom labels.


				

Icons

You can also have icons inside label tag. Unfortunately, the width doesn't scale along with text so you'll need to specify the width of the toggle if you're going have custom labels.


				

Font Size

The font size inside each label can be easily overridden with css.


				

Animation

Animation speed can be easily controlled with css transition property on .toggle-group. You can also turn animation off completely.


				

Notes


Known Issues

There exists a browser issue on webkit for MacOS where border-radius does not get respected on background images. This does not seem to be happening on Windows but only on webkit MacOS.

BUG Webkit Bug 23166

BUG Chromium Issue 72014

Chrome Issue 72014 has been resolved on and will be available by Chrome 24 release. Testing on Canary channel has verified that it's been fixed. As for Safari on MacOS support, It's still waiting for a fix. Please raise the issue with browser developers to escalate the matter if you wish to see it fixed.

I did find some workarounds to this issues by resorting to not using position properties, but by solving the border clipping issues other limitations followed so the idea was abandonded.