Buttons

Angular Buttons - Bootstrap 5 & Material Design 2.0 components

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


Basic example


          <button type="button" class="btn btn-primary">Button</button>
        

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.


Colors

MDB includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.


          <button type="button" class="btn btn-primary">Primary</button>
          <button type="button" class="btn btn-secondary">Secondary</button>
          <button type="button" class="btn btn-success">Success</button>
          <button type="button" class="btn btn-danger">Danger</button>
          <button type="button" class="btn btn-warning">Warning</button>
          <button type="button" class="btn btn-info">Info</button>
          <button type="button" class="btn btn-light">Light</button>
          <button type="button" class="btn btn-dark">Dark</button>
          <button type="button" class="btn btn-link">Link</button>
        

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.


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.


          <button type="button" class="btn btn-outline-primary">
            Primary
          </button>
          <button type="button" class="btn btn-outline-secondary">
            Secondary
          </button>
          <button type="button" class="btn btn-outline-success">
            Success
          </button>
          <button type="button" class="btn btn-outline-danger">
            Danger
          </button>
          <button type="button" class="btn btn-outline-warning">
            Warning
          </button>
          <button type="button" class="btn btn-outline-info">
            Info
          </button>
          <button type="button" class="btn btn-outline-light">
            Light
          </button>
          <button type="button" class="btn btn-outline-dark">
            Dark
          </button>
        

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">Primary</button>
          <button type="button" class="btn btn-secondary btn-rounded">Secondary</button>
          <button type="button" class="btn btn-success btn-rounded">Success</button>
          <button type="button" class="btn btn-danger btn-rounded">Danger</button>
          <button type="button" class="btn btn-warning btn-rounded">Warning</button>
          <button type="button" class="btn btn-info btn-rounded">Info</button>
          <button type="button" class="btn btn-light btn-rounded">Light</button>
          <button type="button" class="btn btn-dark btn-rounded">Dark</button>
        

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">
            Primary
          </button>
          <button type="button" class="btn btn-outline-secondary btn-rounded">
            Secondary
          </button>
          <button type="button" class="btn btn-outline-success btn-rounded">
            Success
          </button>
          <button type="button" class="btn btn-outline-danger btn-rounded">
            Danger
          </button>
          <button type="button" class="btn btn-outline-warning btn-rounded">
            Warning
          </button>
          <button type="button" class="btn btn-outline-info btn-rounded">
            Info
          </button>
          <button type="button" class="btn btn-outline-light btn-rounded">
            Light
          </button>
          <button type="button" class="btn btn-outline-dark btn-rounded">
            Dark
          </button>
        

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">
            <i class="fas fa-download"></i>
          </button>
        

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">
            <i class="fab fa-facebook-f"></i>
          </button>
          <button type="button" class="btn btn-outline-success btn-floating">
            <i class="fas fa-star"></i>
          </button>
          <button type="button" class="btn btn-danger btn-floating">
            <i class="fas fa-magic"></i>
          </button>
          <button type="button" class="btn btn-dark btn-floating">
            <i class="fab fa-apple"></i>
          </button>
        

Social

Combining our icons and custom colors you can create social buttons. 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).

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 btn-primary" style="background-color: #3b5998;" href="#!" role="button"
            ><i class="fab fa-facebook-f"></i
          ></a>
        

Sample brands

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


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

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

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

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

            <!-- Linkedin -->
            <a class="btn btn-primary" style="background-color: #0082ca;" href="#!" role="button"
              ><i class="fab fa-linkedin-in"></i
            ></a>

            <!-- Pinterest -->
            <a class="btn btn-primary" style="background-color: #c61118;" href="#!" role="button"
              ><i class="fab fa-pinterest"></i
            ></a>

            <!-- Vkontakte -->
            <a class="btn btn-primary" style="background-color: #4c75a3;" href="#!" role="button"
              ><i class="fab fa-vk"></i
            ></a>

            <!-- Stack overflow -->
            <a class="btn btn-primary" style="background-color: #ffac44;" href="#!" role="button"
              ><i class="fab fa-stack-overflow"></i
            ></a>

            <!-- Youtube -->
            <a class="btn btn-primary" style="background-color: #ed302f;" href="#!" role="button"
              ><i class="fab fa-youtube"></i
            ></a>

            <!-- Slack -->
            <a class="btn btn-primary" style="background-color: #481449;" href="#!" role="button"
              ><i class="fab fa-slack-hash"></i
            ></a>

            <!-- Github -->
            <a class="btn btn-primary" style="background-color: #333333;" href="#!" role="button"
              ><i class="fab fa-github"></i
            ></a>

            <!-- Dribbble -->
            <a class="btn btn-primary" style="background-color: #ec4a89;" href="#!" role="button"
              ><i class="fab fa-dribbble"></i
            ></a>

            <!-- Reddit -->
            <a class="btn btn-primary" style="background-color: #ff4500;" href="#!" role="button"
              ><i class="fab fa-reddit-alien"></i
            ></a>

            <!-- Whatsapp -->
            <a class="btn btn-primary" style="background-color: #25d366;" href="#!" role="button"
              ><i class="fab fa-whatsapp"></i
            ></a>
          

Floating social

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


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

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.

Twitter

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

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.

8

            <a class="btn btn-primary" style="background-color: #3b5998;" href="#!" role="button"
              ><i class="fab fa-facebook-f"></i><span class="badge bg-danger ms-2">8</span></a
            >
          

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.

Link

          <a class="btn btn-primary" href="#" role="button">Link</a>
          <button class="btn btn-primary" type="submit">Button</button>
          <input class="btn btn-primary" type="button" value="Input" />
          <input class="btn btn-primary" type="submit" value="Submit" />
          <input class="btn btn-primary" type="reset" value="Reset" />
        

Sizes

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


          <button type="button" class="btn btn-primary btn-sm">Button</button>
          <button type="button" class="btn btn-primary">Button</button>
          <button type="button" class="btn btn-primary btn-lg">Button</button>
        

Active state

Add .active class to make the button look pressed.

Primary link Link

          <a href="#" class="btn btn-primary btn-lg active" role="button" aria-pressed="true"
            >Primary link</a
          >
          <a href="#" class="btn btn-secondary btn-lg active" role="button" aria-pressed="true"
            >Link</a
          >
        

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" disabled>Primary button</button>
          <button type="button" class="btn btn-secondary btn-lg" disabled>Button</button>
        

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 should include the aria-disabled="true" attribute to indicate the state of the element to assistive technologies.
Primary link Link

          <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
          >
        

Link functionality caveat:
The .disabled class uses pointer-events: none to try to disable the link functionality of <a>s, but that CSS property is not yet standardized. 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, add a tabindex="-1" attribute on these links (to prevent them from receiving keyboard focus) and use custom JavaScript to disable their functionality.


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">Button</button>
            <button class="btn btn-primary" type="button">Button</button>
          </div>
        

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">Button</button>
            <button class="btn btn-primary" type="button">Button</button>
          </div>
        

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">Button</button>
            <button class="btn btn-primary" type="button">Button</button>
          </div>
        

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">Button</button>
            <button class="btn btn-primary" type="button">Button</button>
          </div>
        

Toggle states

Add .active class and aria-pressed attribute to toggle button active state.


          <button
            type="button"
            [ngClass]="{ 'active': isActive }"
            class="btn btn-primary"
            autocomplete="off"
            (click)="toggleActiveState()"
          >
            Toggle button
          </button>
          <button type="button" class="btn btn-primary" disabled autocomplete="off">
            Disabled toggle button
          </button>
        

          import { Component } from '@angular/core';

          @Component({
            selector: 'app-button',
            templateUrl: './button.component.html',
            styleUrls: ['./button.component.scss'],
          })
          export class ButtonComponent {
            isActive = false;

            toggleActiveState(): void {
              this.isActive = !this.isActive;
            }
          }
        
Toggle link Disabled toggle link

          <a
            href="#"
            class="btn btn-primary"
            role="button"
            [ngClass]="{ 'active': isActive }"
            aria-pressed="isActive"
            (click)="toggleActiveState()"
            >Toggle link</a
          >
          <a href="#" class="btn btn-primary disabled" role="button">Disabled toggle link</a>
        

          import { Component } from '@angular/core';

          @Component({
            selector: 'app-button',
            templateUrl: './button.component.html',
            styleUrls: ['./button.component.scss'],
          })
          export class ButtonComponent {
            isActive = false;

            toggleActiveState(): void {
              this.isActive = !this.isActive;
            }
          }