Buttons

Bootstrap 5 Button component

Responsive Buttons built with Bootstrap 5. Multiple predefined button style classes: button link, outline, round button, social, floating, fixed & more

Use MDB custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.

Note: Read the API tab to find all available options and advanced customization

Required ES init: Button, Ripple *
* UMD autoinits are enabled by default. This means that you don't need to initialize the component manually. However if you are using MDBootstrap ES format then you should pass the required components to the initMDB method.

Video tutorial


Basic example

Use default button style to indicate an action or link within your website.

        
            
            <button type="button" class="btn btn-primary" data-mdb-ripple-init>Button</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Disable text wrapping

If you don’t want the button text to wrap, you can add the .text-nowrap class to the button. In Sass, you can set $btn-white-space: nowrap to disable text wrapping for each button.


Hierarchy

Buttons, as one of the key UI elements, must have their own hierarchy. This means that the user should be able to easily identify which button is the most important (primary button), which is less important (secondary button) and which presents completely additional information (tertiary button).

Elements with strong, filled backgrounds and shadows attract attention the most, which is why button primary is built in this way.

A delicate background without shadows is less engaging, so it is well suited for button secondary.

The lack of background and shadow makes the element the least visible. These features characterize the button tertiary.

Note: Button tertiary may require additional margins. Without extra margins, the button edge will be flush with adjacent elements (which is sometimes the desired result). If you need margin - simply add margin utility classes like mx-2.

        
            
            <button type="button" class="btn btn-primary" data-mdb-ripple-init>Primary</button>
            <button type="button" class="btn btn-secondary" data-mdb-ripple-init>Secondary</button>
            <button type="button" class="btn btn-tertiary" data-mdb-ripple-init data-mdb-ripple-color="light">Tertiary</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Contextual

MDB includes several predefined button styles, each serving its own semantic purpose.

        
            
            <button type="button" class="btn btn-success" data-mdb-ripple-init>Success</button>
            <button type="button" class="btn btn-danger" data-mdb-ripple-init>Danger</button>
            <button type="button" class="btn btn-warning" data-mdb-ripple-init>Warning</button>
            <button type="button" class="btn btn-info" data-mdb-ripple-init>Info</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Conveying meaning to assistive technologies:
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.


Neutral

Neutral buttons provide additional light and dark colors.

        
            
            <button type="button" class="btn btn-light" data-mdb-ripple-init data-mdb-ripple-color="dark">Light</button>
            <button type="button" class="btn btn-dark" data-mdb-ripple-init>Dark</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    


Outline

In need of a button, but not the hefty background colors they bring? Replace the default modifier classes with the .btn-outline-* ones to remove all background images and colors on any button.

In the outline buttons, we recommend adding data-mdb-ripple-color="dark" to change the color of the ripple effect. The default light color of the ripple (applied automatically to every button) may not be well visible in the case of light and outline buttons.

To learn more about the ripple effect and all the available options have a look at Ripple Docs.

        
            
            <button type="button" class="btn btn-outline-primary" data-mdb-ripple-init data-mdb-ripple-color="dark">Primary</button>
            <button type="button" class="btn btn-outline-secondary" data-mdb-ripple-init data-mdb-ripple-color="dark">Secondary</button>
            <button type="button" class="btn btn-outline-success" data-mdb-ripple-init data-mdb-ripple-color="dark">Success</button>
            <button type="button" class="btn btn-outline-danger" data-mdb-ripple-init data-mdb-ripple-color="dark">Danger</button>
            <button type="button" class="btn btn-outline-warning" data-mdb-ripple-init data-mdb-ripple-color="dark">Warning</button>
            <button type="button" class="btn btn-outline-info" data-mdb-ripple-init data-mdb-ripple-color="dark">Info</button>
            <button type="button" class="btn btn-outline-light" data-mdb-ripple-init data-mdb-ripple-color="dark">Light</button>
            <button type="button" class="btn btn-outline-dark" data-mdb-ripple-init data-mdb-ripple-color="dark">Dark</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Some of the button styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.


Rounded

Add .btn-rounded class to make the button rounded.

        
            
            <button type="button" class="btn btn-primary btn-rounded" data-mdb-ripple-init>Primary</button>
            <button type="button" class="btn btn-secondary btn-rounded" data-mdb-ripple-init>Secondary</button>
            <button type="button" class="btn btn-success btn-rounded" data-mdb-ripple-init>Success</button>
            <button type="button" class="btn btn-danger btn-rounded" data-mdb-ripple-init>Danger</button>
            <button type="button" class="btn btn-warning btn-rounded" data-mdb-ripple-init>Warning</button>
            <button type="button" class="btn btn-info btn-rounded" data-mdb-ripple-init>Info</button>
            <button type="button" class="btn btn-light btn-rounded" data-mdb-ripple-init>Light</button>
            <button type="button" class="btn btn-dark btn-rounded" data-mdb-ripple-init>Dark</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Rounded outline

You can use .btn-outline-* and .btn-rounded together to make the button outline and rounded at the same time.

        
            
            <button type="button" class="btn btn-outline-primary btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Primary</button>
            <button type="button" class="btn btn-outline-secondary btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Secondary</button>
            <button type="button" class="btn btn-outline-success btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Success</button>
            <button type="button" class="btn btn-outline-danger btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Danger</button>
            <button type="button" class="btn btn-outline-warning btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Warning</button>
            <button type="button" class="btn btn-outline-info btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Info</button>
            <button type="button" class="btn btn-outline-light btn-rounded" data-mdb-ripple-init data-mdb-ripple-color="dark">Light</button>
            <button type="button" class="btn btn-outline-dark btn-rounded" data-mdb-ripple-init  data-mdb-ripple-color="dark">Dark</button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Floating

Use .btn-floating class to make a circle button.

To make it works properly you have to put an icon inside. The text will not fit in. You can find hundreds of available icons in our icons docs.

        
            
            <button type="button" class="btn btn-primary btn-floating" data-mdb-ripple-init>
              <i class="fas fa-download"></i>
            </button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

You can apply almost all the same classes and attributes to the floating buttons as to the regular buttons - colors, ripples, sizes, outline, etc.

        
            
            <button type="button" class="btn btn-primary btn-lg btn-floating" data-mdb-ripple-init>
              <i class="fas fa-gem"></i>
            </button>
            <button type="button" class="btn btn-outline-success btn-floating" data-mdb-ripple-init data-mdb-ripple-color="dark">
              <i class="fas fa-star"></i>
            </button>
            <button type="button" class="btn btn-danger btn-floating" data-mdb-ripple-init>
              <i class="fas fa-magic"></i>
            </button>
            <button type="button" class="btn btn-dark btn-floating" data-mdb-ripple-init>
              <i class="fab fa-apple"></i>
            </button>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Fixed buttons

Use .fixed-action-btn class to create a fixed button with a list of available options that shows on hover or click.

See the live example of a fixed button in the bottom right corner of this page.

Note: There are available show/hide methods to manually open and close the list. Read the API tab to find more info.

        
            
          <div class="fixed-action-btn" id="fixed1" data-mdb-button-init data-mdb-ripple-init>
            <a class="btn btn-floating text-white btn-lg" data-mdb-button-init data-mdb-ripple-init style="background-color: #f44336;">
              <i class="fas fa-pencil-alt"></i>
            </a>

            <ul class="list-unstyled">
              <li>
                <a class="btn text-white btn-floating btn-lg" data-mdb-button-init data-mdb-ripple-init style="background-color: #f44336;"
                  ><i class="fas fa-star"></i
                ></a>
              </li>
              <li>
                <a class="btn text-white btn-floating btn-lg" data-mdb-button-init data-mdb-ripple-init style="background-color: #fdd835;"
                  ><i class="fas fa-user"></i
                ></a>
              </li>
              <li>
                <a class="btn text-white btn-floating btn-lg" data-mdb-button-init data-mdb-ripple-init style="background-color: #4caf50;"
                  ><i class="fas fa-envelope"></i
                ></a>
              </li>
              <li>
                <a class="btn text-white btn-floating btn-lg" data-mdb-button-init data-mdb-ripple-init style="background-color: #2196f3;"
                  ><i class="fas fa-shopping-cart"></i
                ></a>
              </li>
            </ul>
          </div>
          
        
    
        
            
            // Initialization for ES Users
            import { Button, Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Button, Ripple });
          
        
    
        
            
            <div class="fixed-action-btn" data-mdb-ripple-init data-mdb-button-init>
              <a class="btn btn-floating text-white btn-lg" data-mdb-ripple-init style="background-color: #f44336">
                <i class="fas fa-pencil-alt"></i>
              </a>

              <ul class="list-unstyled">
                <li>
                  <a class="btn text-white btn-floating btn-lg" data-mdb-ripple-init style="background-color: #f44336">
                    <i class="fas fa-star"></i>
                  </a>
                </li>
                <li>
                  <a class="btn text-white btn-floating btn-lg" data-mdb-ripple-init style="background-color: #fdd835">
                    <i class="fas fa-user"></i>
                  </a>
                </li>
                <li>
                  <a class="btn text-white btn-floating btn-lg" data-mdb-ripple-init style="background-color: #4caf50">
                    <i class="fas fa-envelope"></i>
                  </a>
                </li>
                <li>
                  <a class="btn text-white btn-floating btn-lg" data-mdb-ripple-init style="background-color: #2196f3">
                    <i class="fas fa-shopping-cart"></i>
                  </a>
                </li>
              </ul>
            </div>
          
        
    
        
            
            // Initialization for ES Users
            import { Button, Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Button, Ripple });
          
        
    

Social

Combining our icons and custom colors you can create social buttons. See all available icons in our icons search (check "brands" to filter brand icons).

Note: If you use custom colors you need to remove our predefined color classes like .btn-primary or .btn-danger. Instead of this, you need to add class .text-white>.

In the example below, we place a Facebook icon <i class="fab fa-facebook-f"></i> inside the button and set a background-color to #3B5998 (facebook brand color).

        
            
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #3b5998;" href="#!" role="button">
              <i class="fab fa-facebook-f"></i>
            </a>
          
        
    
        
            
            // Initialization for ES Users
            import { Button, initMDB } from "mdb-ui-kit";

            initMDB({ Button });
          
        
    

Sample brands

A few the most popular brands in form of social buttons.

        
            
            <!-- Facebook -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #3b5998;" href="#!" role="button">
              <i class="fab fa-facebook-f"></i>
            </a>

            <!-- Twitter -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #55acee;" href="#!" role="button">
              <i class="fab fa-twitter"></i>
            </a>

            <!-- Google -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #dd4b39;" href="#!" role="button">
              <i class="fab fa-google"></i>
            </a>

            <!-- Instagram -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #ac2bac;" href="#!" role="button">
              <i class="fab fa-instagram"></i>
            </a>

            <!-- Linkedin -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #0082ca;" href="#!" role="button">
              <i class="fab fa-linkedin-in"></i>
            </a>

            <!-- Pinterest -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #c61118;" href="#!" role="button">
              <i class="fab fa-pinterest"></i>
            </a>

            <!-- Vkontakte -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #4c75a3;" href="#!" role="button">
              <i class="fab fa-vk"></i>
            </a>

            <!-- Stack overflow -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #ffac44;" href="#!" role="button">
              <i class="fab fa-stack-overflow"></i>
            </a>

            <!-- Youtube -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #ed302f;" href="#!" role="button">
              <i class="fab fa-youtube"></i>
            </a>

            <!-- Slack -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #481449;" href="#!" role="button">
              <i class="fab fa-slack-hash"></i>
            </a>

            <!-- Github -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #333333;" href="#!" role="button">
              <i class="fab fa-github"></i>
            </a>

            <!-- Dribbble -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #ec4a89;" href="#!" role="button">
              <i class="fab fa-dribbble"></i>
            </a>

            <!-- Reddit -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #ff4500;" href="#!" role="button">
              <i class="fab fa-reddit-alien"></i>
            </a>

            <!-- Whatsapp -->
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #25d366;" href="#!" role="button">
              <i class="fab fa-whatsapp"></i>
            </a>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Floating social

By adding .btn-floating class you can create a nice, floating social button.

        
            
            <a class="btn text-white btn-lg btn-floating" data-mdb-ripple-init style="background-color: #ac2bac;" href="#!" role="button">
              <i class="fab fa-instagram"></i>
            </a>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Text

You don't need to use only an icon. You can add text to the button. Remember to add some spacing classes (for example .me-2) to provide a proper space between icon and text.

        
            
            <a class="btn text-white" data-mdb-ripple-init style="background-color: #55acee;" href="#!" role="button">
              <i class="fab fa-twitter me-2"></i>
              Twitter
            </a>
          
        
    
        
            
            // Initialization for ES Users
            import { Ripple, initMDB } from "mdb-ui-kit";

            initMDB({ Ripple });
          
        
    

Only icon

By removing button classes and replacing background-color with color you can create minimalistic, clickable icons.

        
            
              <!-- Facebook -->
              <a style="color: #3b5998;" href="#!" role="button">
                <i class="fab fa-facebook-f fa-lg"></i>
              </a>

              <!-- Twitter -->
              <a style="color: #55acee;" href="#!" role="button">
                <i class="fab fa-twitter fa-lg"></i>
              </a>

              <!-- Google -->
              <a style="color: #dd4b39;" href="#!" role="button">
                <i class="fab fa-google fa-lg"></i>
              </a>

              <!-- Instagram -->
              <a style="color: #ac2bac;" href="#!" role="button">
                <i class="fab fa-instagram fa-lg"></i>
              </a>
            
        
    

Notifications

By using a badge you can create a button with a notification to provide a counter.

        
            
                <a class="btn text-white" data-mdb-ripple-init style="background-color: #3b5998;" href="#!" role="button">
                  <i class="fab fa-facebook-f"></i>
                  <span class="badge bg-danger ms-2">8</span>
                </a>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Tags

The .btn classes are designed to be used with the <button> element. However, you can also use these classes on <a> or <input> elements (though some browsers may apply a slightly different rendering).

When using button classes on <a> elements that are used to trigger in-page functionality (like collapsing content), rather than linking to new pages or sections within the current page, these links should be given a role="button" to appropriately convey their purpose to assistive technologies such as screen readers.

        
            
                <a class="btn btn-primary" data-mdb-ripple-init href="#" role="button">Link</a>
                <button class="btn btn-primary" data-mdb-ripple-init type="submit">Button</button>
                <input class="btn btn-primary" data-mdb-ripple-init type="button" value="Input" />
                <input class="btn btn-primary" data-mdb-ripple-init type="submit" value="Submit" />
                <input class="btn btn-primary" data-mdb-ripple-init type="reset" value="Reset" />
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Sizes

Fancy larger or smaller buttons? Add .btn-lg or .btn-sm for additional sizes.

        
            
                <button type="button" class="btn btn-primary btn-sm" data-mdb-ripple-init>Button</button>
                <button type="button" class="btn btn-primary" data-mdb-ripple-init>Button</button>
                <button type="button" class="btn btn-primary btn-lg" data-mdb-ripple-init>Button</button>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Active state

Add .active class to make the button look pressed.

        
            
                <a href="#" class="btn btn-primary btn-lg active" data-mdb-ripple-init role="button" aria-pressed="true">Primary link</a>
                <a href="#" class="btn btn-secondary btn-lg active" data-mdb-ripple-init role="button" aria-pressed="true">Link</a>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Disabled state

Make buttons look inactive by adding the disabled boolean attribute to any <button> element. Disabled buttons have pointer-events: none applied to, preventing hover and active states from triggering.

        
            
                <button type="button" class="btn btn-primary btn-lg" data-mdb-ripple-init disabled>Primary button</button>
                <button type="button" class="btn btn-secondary btn-lg" data-mdb-ripple-init disabled>Button</button>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Disabled buttons using the <a> element behave a bit different:

  • <a>s don’t support the disabled attribute, so you must add the .disabled class to make it visually appear disabled.
  • Some future-friendly styles are included to disable all pointer-events on anchor buttons. In browsers which support that property, you won’t see the disabled cursor at all.
  • Disabled buttons using <a> should include the aria-disabled="true" attribute to indicate the state of the element to assistive technologies.
  • Disabled buttons using <a> should not include the href attribute.
        
            
                <a class="btn btn-primary btn-lg disabled" role="button" aria-disabled="true">Primary link</a>
                <a class="btn btn-secondary btn-lg disabled" role="button" aria-disabled="true">Link</a>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Link functionality caveat:
To cover cases where you have to keep the href attribute on a disabled link, the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s. Note that this CSS property is not yet standardized for HTML, but all modern browsers support it. In addition, even in browsers that do support pointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, in addition to aria-disabled="true", also include a tabindex="-1" attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.

        
            
                <a href="#" class="btn btn-primary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
                <a href="#" class="btn btn-secondary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Link</a>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Block buttons

Create responsive stacks of full-width, “block buttons” like those in Bootstrap 4 with a mix of our display and gap utilities. By using utilities instead of button specific classes, we have much greater control over spacing, alignment, and responsive behaviors.

        
            
                <div class="d-grid gap-2">
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                </div>
            
        
    
        
            
              // Initialization for ES Users
              import { Ripple, initMDB } from "mdb-ui-kit";

              initMDB({ Ripple });
            
        
    

Here we create a responsive variation, starting with vertically stacked buttons until the md breakpoint, where .d-md-block replaces the .d-grid class, thus nullifying the gap-2 utility. Resize your browser to see them change.

        
            
                <div class="d-grid gap-2 d-md-block">
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                </div>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

You can adjust the width of your block buttons with grid column width classes. For example, for a half-width “block button”, use .col-6. Center it horizontally with .mx-auto, too.

        
            
                <div class="d-grid gap-2 col-6 mx-auto">
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                </div>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we’ve taken our previous responsive example and added some flex utilities and a margin utility on the button to right align the buttons when they’re no longer stacked.

        
            
                <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                  <button class="btn btn-primary me-md-2" type="button" data-mdb-ripple-init>Button</button>
                  <button class="btn btn-primary" type="button" data-mdb-ripple-init>Button</button>
                </div>
              
        
    
        
            
                // Initialization for ES Users
                import { Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Ripple });
              
        
    

Toggle states

Add data-mdb-toggle="button" to toggle a button’s active state. If you’re pre-toggling a button, you must manually add the .active class and aria-pressed="true" to the <button>.

        
            
                <button type="button" class="btn btn-primary" data-mdb-toggle="button" data-mdb-button-init data-mdb-ripple-init autocomplete="off">
                  Toggle button
                </button>
                <button type="button" class="btn btn-primary active" data-mdb-toggle="button" data-mdb-button-init data-mdb-ripple-init autocomplete="off" aria-pressed="true">
                  Active toggle button
                </button>
                <button type="button" class="btn btn-primary" disabled data-mdb-toggle="button" data-mdb-button-init data-mdb-ripple-init autocomplete="off">
                  Disabled toggle button
                </button>
              
        
    
        
            
                // Initialization for ES Users
                import { Button, Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Button, Ripple });
              
        
    
        
            
                <a href="#" class="btn btn-primary" role="button" data-mdb-toggle="button" data-mdb-button-init data-mdb-ripple-init>Toggle link</a>
                <a href="#" class="btn btn-primary active" role="button" data-mdb-toggle="button" data-mdb-button-init data-mdb-ripple-init aria-pressed="true">Active toggle link</a> 
                <a class="btn btn-primary disabled" role="button" data-mdb-toggle="button" data-mdb-button-init data-mdb-ripple-init>Disabled toggle link</a>
              
        
    
        
            
                // Initialization for ES Users
                import { Button, Ripple, initMDB } from "mdb-ui-kit";

                initMDB({ Button, Ripple });
              
        
    

Buttons - API


Import

Importing components depends on how your application works. If you intend to use the MDBootstrap ES format, you must first import the component and then initialize it with the initMDB method. If you are going to use the UMD format, just import the mdb-ui-kit package.

        
            
          import { Button, initMDB } from "mdb-ui-kit";
          
          initMDB({ Button });
        
        
    
        
            
          import "mdb-ui-kit"
        
        
    

Usage

Via data attributes

Using the Button component doesn't require any additional JavaScript code - simply add data-mdb-button-init attribute to .btn if your using fixed buttons or toggle buttons and use other data attributes to set all options. For ES format, you must first import and call the initMDB method.

        
            
          <button class="btn btn-primary" data-mdb-ripple-init>
            Example button
          </button>
        
        
    

Via JavaScript

        
            
          const element = document.querySelector('.btn');
          const instance = new Button(element);
        
        
    
        
            
          const element = document.querySelector('.btn');
          const instance = new mdb.Button(element);
        
        
    

Via jQuery

Note: By default, MDB does not include jQuery and you have to add it to the project on your own.

        
            
          $(document).ready(() => {
            $('#exampleID').button('methodName');
          });
        
        
    

Methods

Method Description Example
dispose Destroys an element's button. instance.dispose()
getInstance Static method which allows you to get the button instance associated to a DOM element. Button.getInstance(button)
getOrCreateInstance Static method which returns a button instance associated to a DOM element or create a new one in case it wasn't initialized. Button.getOrCreateInstance(button)
toggle Toggles push state. Gives the button the appearance that it has been activated. instance.toggle()
show Manually opens fixed button list. instance.show()
hide Manually hides fixed button list. instance.hide()
        
            
          const buttons = document.querySelectorAll('.btn')
          buttons.forEach((button) => {
            const button = new Button(button)
            button.toggle()
          })
        
        
    
        
            
        const buttons = document.querySelectorAll('.btn')
        buttons.forEach((button) => {
          const button = new mdb.Button(button)
          button.toggle()
        })
      
        
    

Events

Name Description
show.mdb.button This event fires immediately when the fixed button show method has been called.
shown.mdb.button This event is fired when a fixed button list has been made visible to the user (will wait for CSS transitions to complete).
hide.mdb.button This event is fired immediately when the fixed button hide method has been called.
hidden.mdb.button This event is fired when a fixed button list has been hidden from the user (will wait for CSS transitions to complete).
        
            
          const myFixedButton = document.getElementById('myFixedButton')
          myFixedButton.addEventListener('show.mdb.button', function (e) {
            // do something...
          })
        
        
    

CSS variables

As part of MDB’s evolving CSS variables approach, buttons now use local CSS variables on .btn for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

Button's CSS variables are in different classes which belong to this component. To make it easier to use them, you can find below all of the used CSS variables.

        
            
        // .btn
        --#{$prefix}btn-padding-x: #{$btn-padding-x};
        --#{$prefix}btn-padding-y: #{$btn-padding-y};
        --#{$prefix}btn-padding-top: #{$btn-padding-top};
        --#{$prefix}btn-padding-bottom: #{$btn-padding-bottom};
        --#{$prefix}btn-font-family: #{$btn-font-family};
        @include rfs($btn-font-size, --#{$prefix}btn-font-size);
        --#{$prefix}btn-font-weight: #{$btn-font-weight};
        --#{$prefix}btn-line-height: #{$btn-line-height};
        --#{$prefix}btn-color: #{$body-color};
        --#{$prefix}btn-bg: transparent;
        --#{$prefix}btn-border-width: 0;
        --#{$prefix}btn-border-color: none;
        --#{$prefix}btn-border-radius: #{$btn-border-radius};
        --#{$prefix}btn-hover-border-color: transparent;
        --#{$prefix}btn-box-shadow: #{$btn-box-shadow};
        --#{$prefix}btn-hover-box-shadow: #{$btn-hover-box-shadow};
        --#{$prefix}btn-focus-box-shadow: #{$btn-focus-box-shadow};
        --#{$prefix}btn-active-box-shadow: #{$btn-active-box-shadow};
        --#{$prefix}btn-disabled-opacity: #{$btn-disabled-opacity};
        --#{$prefix}btn-focus-box-shadow: 0 0 0 #{$btn-focus-width} rgba(var(--#{$prefix}btn-focus-shadow-rgb), 0.5);

        // [class*='btn-outline-']
        --#{$prefix}btn-padding-top: #{$btn-outline-padding-top};
        --#{$prefix}btn-padding-bottom: #{$btn-outline-padding-bottom};
        --#{$prefix}btn-padding-x: #{$btn-outline-padding-x};
        --#{$prefix}btn-border-width: #{$btn-outline-border-width};
        --#{$prefix}btn-line-height: #{$btn-line-height};
        
        // .btn-link
        --#{$prefix}btn-font-weight: #{$font-weight-medium};
        --#{$prefix}btn-color: #{$btn-link-color};
        --#{$prefix}btn-bg: transparent;
        --#{$prefix}btn-border-color: transparent;
        --#{$prefix}btn-hover-color: #{$btn-link-hover-color};
        --#{$prefix}btn-hover-bg: #{$btn-link-hover-bg};
        --#{$prefix}btn-hover-border-color: transparent;
        --#{$prefix}btn-focus-color: #{$btn-link-focus-color};
        --#{$prefix}btn-active-color: #{$btn-link-active-color};
        --#{$prefix}btn-active-border-color: transparent;
        --#{$prefix}btn-disabled-color: #{$btn-link-disabled-color};
        --#{$prefix}btn-disabled-border-color: transparent;
        --#{$prefix}btn-box-shadow: none;
        --#{$prefix}btn-focus-shadow-rgb: #{to-rgb(mix(color-contrast($primary), $primary, 15%))};
        
        // .btn-tertiary
        --#{$prefix}btn-font-weight: #{$font-weight-medium};
        --#{$prefix}btn-color: #{$btn-link-color};
        --#{$prefix}btn-hover-color: #{$btn-link-hover-color};
        --#{$prefix}btn-hover-bg: transparent;
        --#{$prefix}btn-focus-color: #{$btn-link-focus-color};
        --#{$prefix}btn-active-color: #{$btn-link-active-color};
        --#{$prefix}btn-disabled-color: #{$btn-link-disabled-color};
        --#{$prefix}btn-box-shadow: none;
        
        // .btn-rounded
        --#{$prefix}btn-border-radius: #{$btn-rounded-border-radius};
        
        // .btn-floating,
        // [class*='btn-outline-'].btn-floating
        --#{$prefix}btn-border-radius: #{$btn-floating-border-radius};
        
        // .btn-floating
        --#{$prefix}btn-width: #{$btn-floating-width};
        --#{$prefix}btn-height: #{$btn-floating-height};
        --#{$prefix}btn-icon-width: #{$btn-floating-icon-width};
        --#{$prefix}btn-icon-line-height: #{$btn-floating-icon-line-height};
        --#{$prefix}btn-width-lg: #{$btn-floating-width-lg};
        --#{$prefix}btn-height-lg: #{$btn-floating-height-lg};
        --#{$prefix}btn-icon-width-lg: #{$btn-floating-icon-width-lg};
        --#{$prefix}btn-icon-line-height-lg: #{$btn-floating-icon-line-height-lg};
        --#{$prefix}btn-width-sm: #{$btn-floating-width-sm};
        --#{$prefix}btn-height-sm: #{$btn-floating-height-sm};
        --#{$prefix}btn-icon-width-sm: #{$btn-floating-icon-width-sm};
        --#{$prefix}btn-icon-line-height-sm: #{$btn-floating-icon-line-height-sm};
        
        // [class*='btn-outline-'].btn-floating
        --#{$prefix}btn-icon-width: #{$btn-outline-floating-icon-width};
        --#{$prefix}btn-icon-width-lg: #{$btn-outline-floating-icon-width-lg};
        --#{$prefix}btn-icon-width-sm: #{$btn-outline-floating-icon-width-sm};
        --#{$prefix}btn-icon-line-height: #{$btn-outline-floating-icon-line-height};
        --#{$prefix}btn-icon-line-height-lg: #{$btn-outline-floating-icon-line-height-lg};
        --#{$prefix}btn-icon-line-height-sm: #{$btn-outline-floating-icon-line-height-sm};
        
        // .fixed-action-btn
        --#{$prefix}btn-right: #{$fixed-action-btn-right};
        --#{$prefix}btn-bottom: #{$fixed-action-btn-bottom};
        --#{$prefix}btn-zindex: #{$fixed-action-button-zindex};
        --#{$prefix}btn-padding-top: #{$fixed-action-btn-padding-top};
        --#{$prefix}btn-padding-bottom: #{$fixed-action-btn-padding-bottom};
        --#{$prefix}btn-padding-x: #{$fixed-action-btn-padding-x};
        --#{$prefix}btn-margin-bottom: #{$fixed-action-btn-li-margin-bottom};
        
        // .btn-block
        --#{$prefix}btn-margin-top: #{$btn-block-margin-top};            
        
        
    

SCSS variables

        
            
        $btn-color: var(--#{$prefix}body-color);
        $btn-padding-top: 0.625rem;
        $btn-padding-bottom: 0.5rem;
        $btn-padding-x: 1.5rem;
        $btn-padding-y: $input-btn-padding-y;
        $btn-font-size: 0.75rem;
        $btn-line-height: 1.5;
        $btn-font-size: $input-btn-font-size;
        $btn-white-space: null;
        
        $btn-padding-top-lg: 0.75rem;
        $btn-padding-bottom-lg: 0.6875rem;
        $btn-padding-x-lg: 1.6875rem;
        $btn-padding-y-lg: $input-btn-padding-y-lg;
        $btn-font-size-lg: 0.875rem;
        $btn-line-height-lg: 1.6;
        
        $btn-padding-top-sm: 0.375rem;
        $btn-padding-bottom-sm: 0.3125rem;
        $btn-padding-x-sm: 1rem;
        $btn-padding-y-sm: $input-btn-padding-y-sm;
        $btn-font-size-sm: 0.75rem;
        $btn-line-height-sm: 1.5;
        
        $btn-border-width: $border-width-alternate;
        
        $btn-font-weight: $font-weight-medium;
        $btn-box-shadow: 0 4px 9px -4px rgba($black, 0.35);
        $btn-hover-box-shadow: 0 8px 9px -4px rgba($black, 0.15), 0 4px 18px 0 rgba($black, 0.1);
        $btn-focus-box-shadow: $btn-hover-box-shadow;
        $btn-active-box-shadow: $btn-focus-box-shadow;
        $btn-focus-width: $input-btn-focus-width;
        $btn-disabled-opacity: 0.65;
        
        $btn-link-color: $link-color;
        $btn-link-hover-color: $link-hover-color;
        $btn-link-focus-color: $link-focus-color;
        $btn-link-active-color: $link-active-color;
        $btn-link-disabled-color: $gray-500;
        $btn-link-hover-bg: hsl(0, 0%, 96%);
        $btn-link-focus-shadow-rgb: to-rgb(mix(color-contrast($link-color), $link-color, 15%));

        $btn-border-radius: $border-radius;
        $btn-border-radius: var(--#{$prefix}border-radius);
        $btn-border-radius-sm: var(--#{$prefix}border-radius-sm);
        $btn-border-radius-lg: var(--#{$prefix}border-radius-lg);

        $btn-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
          border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
        
        $btn-hover-bg-shade-amount: 5%;
        $btn-focus-bg-shade-amount: 5%;
        $btn-active-bg-shade-amount: 10%;

        $btn-hover-bg-tint-amount: 5%;
        $btn-focus-bg-tint-amount: 5%;
        $btn-active-bg-tint-amount: 10%;

        $btn-secondary-bg-tint-amount: 85%;
        $btn-secondary-color-shade-amount: 30%;
        $btn-light-color-tint-amount: 30%;
        
        $btn-contextual-box-shadow: 0 4px 9px -4px;
        $btn-contextual-box-shadow-state-first-part: 0 8px 9px -4px;
        $btn-contextual-box-shadow-state-second-part: 0 4px 18px 0;
        
        $btn-outline-padding-top: 0.5rem;
        $btn-outline-padding-bottom: 0.375rem;
        $btn-outline-padding-x: 1.375rem;
        $btn-outline-border-width: $border-width-alternate;
        $btn-outline-line-height: 1.5;
        
        $btn-outline-padding-top-lg: 0.625rem;
        $btn-outline-padding-bottom-lg: 0.5625rem;
        $btn-outline-padding-x-lg: 1.5625rem;
        $btn-outline-font-size-lg: 0.875rem;
        $btn-outline-line-height-lg: 1.6;
        
        $btn-outline-padding-top-sm: 0.25rem;
        $btn-outline-padding-bottom-sm: 0.1875rem;
        $btn-outline-padding-x-sm: 0.875rem;
        $btn-outline-font-size-sm: 0.75rem;
        $btn-outline-line-height-sm: 1.5;
        
        $btn-rounded-border-radius: 10rem;
        
        $btn-floating-border-radius: 50%;
        
        $btn-floating-width: 2.3125rem;
        $btn-floating-height: 2.3125rem;
        $btn-floating-icon-width: 2.3125rem;
        
        $btn-floating-width-lg: 2.8125rem;
        $btn-floating-height-lg: 2.8125rem;
        $btn-floating-icon-width-lg: 2.8125rem;
        
        $btn-floating-width-sm: 1.8125rem;
        $btn-floating-height-sm: 1.8125rem;
        $btn-floating-icon-width-sm: 1.8125rem;
        
        $btn-outline-floating-icon-width: 2.0625rem;
        $btn-outline-floating-icon-width-lg: 2.5625rem;
        $btn-outline-floating-icon-width-sm: 1.5625rem;
        
        $btn-floating-icon-line-height: 2.3125rem;
        $btn-floating-icon-line-height-lg: 2.8125rem;
        $btn-floating-icon-line-height-sm: 1.8125rem;
        
        $btn-outline-floating-icon-line-height: 2.0625rem;
        $btn-outline-floating-icon-line-height-lg: 2.5625rem;
        $btn-outline-floating-icon-line-height-sm: 1.5625rem;
        
        $fixed-action-btn-right: 2.1875rem;
        $fixed-action-btn-bottom: 2.1875rem;
        $fixed-action-btn-padding-top: 0.9375rem;
        $fixed-action-btn-padding-bottom: 1.25rem;
        $fixed-action-btn-padding-x: 1.25rem;
        $fixed-action-btn-li-margin-bottom: 1.5rem;
        
        $btn-block-margin-top: 0.5rem;