Generate Multi-State UI Buttons With jQuery - magicButtons

File Size: 32.4 KB
Views Total: 2010
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Generate Multi-State UI Buttons With jQuery - magicButtons

magicButtons is a simple jQuery plugin for creating multi-state UI buttons on the webpage that allows you to change the button state on click.

The main goal of this plugin is to create an inline loading indicator inside the button for AJAX content loading or form submitting.

More features:

  • 3 button styles: empty, material design, outline.
  • Custom state text and icons.
  • Rounded button borders.
  • Ripple click animation.
  • 3 sizes: Small, Medium and Large.

See also:

How to use it:

1. Load the necessary jQuery JavaScript library and the jQuery magicButtons plugin's files in the html.

<link rel="stylesheet" href="assets/css/main.css">
<script src="" 
<script src="assets/js/magicBtn.js"></script>

2. By default, the plugin uses Font Awesome 5 for the state icons.

<link rel="stylesheet" 

3. Call the function to generate buttons and specify the button style you want to use.

<div id="examples">
  <button id="btn1" class="magicBtn">Button 1</button>
  <button id="btn2" class="magicBtn">Button 2</button>
  <button id="btn3" class="magicBtn">Button 3</button>

  // or 'outline'
  buttonType: 'material' // default: ''

4. Apply a loading state with custom loading text and indicator icon to the button when clicked.

var clickBtn1 = 'true';
$('#btn1').click(function (e) {
  if(clickBtn1 == 'true') {
      loadindText: 'Loading...',
      loadingIcon: true,
    clickBtn1 = 'false';
  } else {
    click = 'true';

5. Set the button to the initial state.

  //Initial text
  text: 'Your Text Here'

6. Apply the disabled state to the button.



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