Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Initial answer from 2013</h1> <p>An excellent (unofficial) <a href="http://bootstrapswitch.site/" rel="nofollow noreferrer">Bootstrap Switch is available</a>. </p> <p><a href="https://i.stack.imgur.com/9QTta.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9QTta.png" alt="Classic 2013 Switch"></a></p> <pre><code>&lt;input type="checkbox" name="my-checkbox" checked&gt; $("[name='my-checkbox']").bootstrapSwitch(); </code></pre> <p>It uses radio types <em>or</em> checkboxes as switches. A <code>type</code> attribute has been added since V.1.8.</p> <p>Source code is <a href="https://github.com/nostalgiaz/bootstrap-switch" rel="nofollow noreferrer">available on Github</a>.</p> <h1>Note from 2018</h1> <p>I would not recommend to use those kind of old Switch buttons now, as they always seemed to <a href="http://ux.stackexchange.com/questions/1318/should-a-toggle-button-show-its-current-state-or-the-state-to-which-it-will-chan">suffer of usability issues</a> as pointed by many people. </p> <p>Please consider having a look at <a href="https://react-component.github.io/switch/examples/simple.html" rel="nofollow noreferrer">modern Switches like this one</a> from the <a href="https://github.com/react-component" rel="nofollow noreferrer">React Component framework</a> (not Bootstrap related, but can be integrated in Bootstrap grid and UI though).</p> <p>Other implementations exist for Angular, View or jQuery.</p> <p><a href="https://i.stack.imgur.com/4E0Uu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4E0Uu.png" alt="Modern 2018 Switch"></a></p> <pre><code>import '../assets/index.less' import React from 'react' import ReactDOM from 'react-dom' import Switch from 'rc-switch' class Switcher extends React.Component { state = { disabled: false, } toggle = () =&gt; { this.setState({ disabled: !this.state.disabled, }) } render() { return ( &lt;div style={{ margin: 20 }}&gt; &lt;Switch disabled={this.state.disabled} checkedChildren={'开'} unCheckedChildren={'关'} /&gt; &lt;/div&gt; &lt;/div&gt; ) } } ReactDOM.render(&lt;Switcher /&gt;, document.getElementById('__react-content')) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload