Skip to content

Instantly share code, notes, and snippets.

Avatar

haley. haleyngonadi

  • Canada
View GitHub Profile
View bootstrap-button-toggle-on-off-switch.markdown

Bootstrap Button Toggle (On/Off Switch)

Working on a client project that will be using Bootstrap, and needed to build a toggle/switch that came in a couple different sizes. I wasn't seeing that as a built-in option within Bootstrap, and I didn't really like the ones already out there that I found from a quick search (I didn't want to use a plugin, just wanted it to utilize Bootstrap's built-in JS), so I decided to make my own.

This example is just using the default "Quick Add" Bootstrap CSS & JS, no added/custom JS on my part, I've simply utilized Bootstrap's buttons.js Single Toggle method (http://getbootstrap.com/javascript/#buttons) and added some custom styling (LESS).

A Pen by Aanjulena Sweet on CodePen.

License.

View routes.php
<?php
...
Router::scope('/artist', ['controller' => 'Artists'], function ($routes) {
$routes->connect('/:id/:name', ['action' => 'view'], ['pass' => ['id']]);
});