Create Multi-state Switches From Buttons - jQuery stateButton

Create Multi-state Switches From Buttons - jQuery stateButton

The stateButton jQuery plugin creates a customizable multi-state toggle button which allows the user to switch between states on click. Ideal for collapse/expand buttons, ladda buttons(inline loading indicators) and more.

1. Insert the JavaScript file jquery.stateButton.js and we're ready to go.

<script src="" 
<script src="jquery.stateButton.js"></script>

2. Create a standard button for the toggle switch.

<button id="toggle">Click Me</button>

3. Active the toggle button which switches between collapse/expand states when clicked (Ideal for multi-level tree view).

  values: [ "Expanded", "Collapsed" ],
  current: "Collapsed"

4. Customize the button text and tooltip content.

  values: [ "Expanded", "Collapsed" ],
  current: "Collapsed",
  text: {
    "expanded" : "Collapse",
    "collapsed": "Expand"
  tooltip: {
    "expanded" : "Collapse all",
    "collapsed": "Expand all"

5. Add additional CSS classes to the toggle button.

  styleClass: {
    "expanded" : "btn-expanded",
    "collapsed": "btn-collapsed"
  inlineStyle: {
    "expanded": {
      "color": "red"
    "collapsed": {
      "color": "green"

6. Execute a callback function when you click the toggle button.

  clickCallback: function(newState, oldState) {
    console.log('button', this);
    console.log('old state', oldState);
    console.log('new state', newState);

7. You can also config the toggle buttons via data-OPTION attributes. Great for multiple toggle buttons on the page.

<button id="toggle"

This awesome jQuery plugin is developed by aprofetb. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 06.03.2018
  • Source

Whoops, looks like something went wrong.

(1/1) ErrorException

file_put_contents(): Only 0 of 251 bytes written, possibly out of free disk space

in Filesystem.php (line 122)
at HandleExceptions->handleError(2, 'file_put_contents(): Only 0 of 251 bytes written, possibly out of free disk space', '/home/p336588/web/', 122, array('path' => '/home/p336588/web/', 'contents' => 'a:3:{s:6:"_token";s:40:"5azn4hpyEgGLtUBAcgvtQqQVqqjUUaOcnO179ftU";s:9:"_previous";a:1:{s:3:"url";s:93:"";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', 'lock' => true))
at file_put_contents('/home/p336588/web/', 'a:3:{s:6:"_token";s:40:"5azn4hpyEgGLtUBAcgvtQqQVqqjUUaOcnO179ftU";s:9:"_previous";a:1:{s:3:"url";s:93:"";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', 2)in Filesystem.php (line 122)
at Filesystem->put('/home/p336588/web/', 'a:3:{s:6:"_token";s:40:"5azn4hpyEgGLtUBAcgvtQqQVqqjUUaOcnO179ftU";s:9:"_previous";a:1:{s:3:"url";s:93:"";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}', true)in FileSessionHandler.php (line 83)
at FileSessionHandler->write('VdqOTNd1jgOGkxiQHHjV7ZHYIqymhNE5dGGz9ynP', 'a:3:{s:6:"_token";s:40:"5azn4hpyEgGLtUBAcgvtQqQVqqjUUaOcnO179ftU";s:9:"_previous";a:1:{s:3:"url";s:93:"";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}')in Store.php (line 128)
at Store->save()in StartSession.php (line 88)
at StartSession->terminate(object(Request), object(Response))in Kernel.php (line 218)
at Kernel->terminateMiddleware(object(Request), object(Response))in Kernel.php (line 189)
at Kernel->terminate(object(Request), object(Response))in index.php (line 58)