Rate this docs

Angular Bootstrap Buttons

Angular Buttons - Bootstrap 4 & Material Design

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


Examples

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



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

      

Basic MDB buttons

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



        <button mdbBtn type="button" color="primary" mdbWavesEffect>Primary</button>
        <button mdbBtn type="button" color="default" mdbWavesEffect>Default</button>
        <button mdbBtn type="button" color="secondary" mdbWavesEffect>Secondary</button>
        <button mdbBtn type="button" color="success" mdbWavesEffect>Success</button>
        <button mdbBtn type="button" color="info" mdbWavesEffect>Info</button>
        <button mdbBtn type="button" color="warning" mdbWavesEffect>Warning</button>
        <button mdbBtn type="button" color="danger" mdbWavesEffect>Danger</button>

      

Additional buttons



        <button mdbBtn type="button" color="elegant" mdbWavesEffect>Elegant</button>
        <button mdbBtn type="button" color="unique" mdbWavesEffect>Unique</button>
        <button mdbBtn type="button" color="pink" mdbWavesEffect>Pink</button>
        <button mdbBtn type="button" color="purple" mdbWavesEffect>Purple</button>
        <button mdbBtn type="button" color="deep-purple" mdbWavesEffect>Deep-Purple</button>
        <button mdbBtn type="button" color="indigo" mdbWavesEffect>Indigo</button>
        <button mdbBtn type="button" color="light-blue" mdbWavesEffect>Light-blue</button>
        <button mdbBtn type="button" color="cyan" mdbWavesEffect>Cyan</button>
        <button mdbBtn type="button" color="dark-green" mdbWavesEffect>Dark-Green</button>
        <button mdbBtn type="button" color="light-green" mdbWavesEffect>Light-green</button>
        <button mdbBtn type="button" color="yellow" mdbWavesEffect>Yellow</button>
        <button mdbBtn type="button" color="amber" mdbWavesEffect>Amber</button>
        <button mdbBtn type="button" color="deep-orange" mdbWavesEffect>Deep-Orange</button>
        <button mdbBtn type="button" color="brown" mdbWavesEffect>Brown</button>
        <button mdbBtn type="button" color="blue-grey" mdbWavesEffect>Blue-Grey</button>
        <button mdbBtn type="button" color="mdb-color" mdbWavesEffect>MDB</button>

      

Gradient buttons

Check our documentation about gradients.



        <button mdbBtn type="button" gradient="peach" rounded="true" mdbWavesEffect>Peach</button>
        <button mdbBtn type="button" gradient="purple" rounded="true" mdbWavesEffect>Purple</button>
        <button mdbBtn type="button" gradient="blue" rounded="true" mdbWavesEffect>Blue</button>
        <button mdbBtn type="button" gradient="aqua" rounded="true" mdbWavesEffect>Aqua</button>

      

Outline buttons

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



          <button mdbBtn type="button" color="primary" outline="true" mdbWavesEffect>Primary</button>
          <button mdbBtn type="button" color="default" outline="true" mdbWavesEffect>Default</button>
          <button mdbBtn type="button" color="secondary" outline="true" mdbWavesEffect>Secondary</button>
          <button mdbBtn type="button" color="success" outline="true" mdbWavesEffect>Success</button>
          <button mdbBtn type="button" color="info" outline="true" mdbWavesEffect>Info</button>
          <button mdbBtn type="button" color="warning" outline="true" mdbWavesEffect>Warning</button>
          <button mdbBtn type="button" color="danger" outline="true" mdbWavesEffect>Danger</button>

        

Waves effect with outline buttons

MDB automatically adds waves effect to each element with .btn class. However, in outline buttons, it's barely visible due to lack of background.

That's why to outline buttons we add additional class .waves-effect to make waves darker and more intense.


Rounded buttons MDB Pro component



        <button mdbBtn type="button" color="primary" rounded="true" mdbWavesEffect>Primary</button>
        <button mdbBtn type="button" color="default" rounded="true" mdbWavesEffect>Default</button>
        <button mdbBtn type="button" color="secondary" rounded="true" mdbWavesEffect>Secondary</button>
        <button mdbBtn type="button" color="success" rounded="true" mdbWavesEffect>Success</button>
        <button mdbBtn type="button" color="info" rounded="true" mdbWavesEffect>Info</button>
        <button mdbBtn type="button" color="warning" rounded="true" mdbWavesEffect>Warning</button>
        <button mdbBtn type="button" color="danger" rounded="true" mdbWavesEffect>Danger</button>

      

Rounded outline buttons MDB Pro component



        <button mdbBtn type="button" color="primary" rounded="true" outline="true" mdbWavesEffect>Primary</button>
        <button mdbBtn type="button" color="default" rounded="true" outline="true" mdbWavesEffect>Default</button>
        <button mdbBtn type="button" color="secondary" rounded="true" outline="true" mdbWavesEffect>Secondary</button>
        <button mdbBtn type="button" color="success" rounded="true" outline="true" mdbWavesEffect>Success</button>
        <button mdbBtn type="button" color="info" rounded="true" outline="true" mdbWavesEffect>Info</button>
        <button mdbBtn type="button" color="warning" rounded="true" outline="true" mdbWavesEffect>Warning</button>
        <button mdbBtn type="button" color="danger" rounded="true" outline="true" mdbWavesEffect>Danger</button>

      

Floating buttons MDB Pro component



        <a mdbBtn floating="true" size="lg" gradient="purple" mdbWavesEffect>
          <mdb-icon icon="bolt"></mdb-icon>
        </a>
        <a mdbBtn floating="true" gradient="peach" mdbWavesEffect>
          <mdb-icon icon="leaf"></mdb-icon>
        </a>
        <a mdbBtn floating="true" size="sm" gradient="blue" mdbWavesEffect>
          <mdb-icon icon="star"></mdb-icon>
        </a>

      

Fixed buttons MDB Pro component

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

Active on click



        <div class="fixed-action-btn" style="bottom: 45px; right: 24px;">

          <a class="btn-floating btn-large red waves-light" mdbWavesEffect (click)="fixed.toggle($event)">
            <i class="fa fa-pencil"></i>
          </a>

          <div class="fixed_collapse" mdbCollapse="isCollapsed" #fixed="bs-collapse">
            <a class="btn-floating red waves-light" mdbWavesEffect><i class="fa fa-star"></i></a>
            <a class="btn-floating yellow darken-1 waves-light" mdbWavesEffect><i class="fa fa-user"></i></a>
            <a class="btn-floating green waves-light" mdbWavesEffect><i class="fa fa-envelope"></i></a>
            <a class="btn-floating blue waves-light" mdbWavesEffect><i class="fa fa-shopping-cart"></i></a>
          </div>

        </div>

      

Active on hover



        <div class="fixed-action-btn" style="bottom: 45px; right: 24px;" (mouseleave)="fixed.toggle()">

          <a class="btn-floating btn-large red waves-light" mdbWavesEffect (mouseenter)="fixed.toggle()">
            <i class="fa fa-pencil"></i>
          </a>

          ...

        </div>

      

Close menu after clicking on a link



        <div class="fixed-action-btn" style="bottom: 45px; right: 24px;">

          <a class="btn-floating btn-large red waves-light" mdbWavesEffect (click)="fixed.toggle($event)">
            <i class="fa fa-pencil"></i>
          </a>

          <div class="fixed_collapse" mdbCollapse="isCollapsed" #fixed="bs-collapse">
            <a class="btn-floating red waves-light" mdbWavesEffect><i class="fa fa-star" (click)="fixed.toggle($event)"></i></a>
            <a class="btn-floating yellow darken-1 waves-light" mdbWavesEffect><i class="fa fa-user"></i></a>
            <a class="btn-floating green waves-light" mdbWavesEffect><i class="fa fa-envelope"></i></a>
            <a class="btn-floating blue waves-light" mdbWavesEffect><i class="fa fa-shopping-cart"></i></a>
          </div>

        </div>

      

"Back to the top" button

"Back to the top" button is very useful with the long pages, especially on the mobile devices.

Click the button below to see the live example.

Live example

Usage: To make it work, you have to set an ID #top-section to any element on the top of the page.



        <button class="btn btn-floating btn-large red waves-light" mdbPageScroll href="#top-section" mdbWavesEffect
          style="right:35px; bottom:35px;" [pageScrollDuration]="750">
          <i class="fa fa-arrow-up"></i>
        </button>

      

Flat button MDB Pro component



        <button mdbBtn type="button" flat="true" size="lg" mdbWavesEffect>Click me</button>

      

Buttons with icons

Note: To set the desired distance between icon and text use spacing utilities (for example .ml-1, .mr-2).



        <button mdbBtn type="button" color="primary" mdbWavesEffect>
          <mdb-icon icon="magic" class="mr-1"></mdb-icon>Left
        </button>
        <button mdbBtn type="button" color="default" mdbWavesEffect>Right<mdb-icon icon="magic" class="ml-1"></mdb-icon></button>

      

Button tags

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

When using mdbBtn directive 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 mdbBtn href="#" role="button" color="primary" mdbWavesEffect>Link</a>
        <button mdbBtn type="submit" color="primary" mdbWavesEffect>Button</button>
        <div class="waves-input-wrapper waves-light" mdbWavesEffect><input mdbBtn color="primary" type="button" value="Input"></div>
        <div class="waves-input-wrapper waves-light" mdbWavesEffect><input mdbBtn color="primary" type="submit" value="Submit"></div>
        <div class="waves-input-wrapper waves-light" mdbWavesEffect><input mdbBtn color="primary" type="reset" value="Reset"></div>

      

Sizes

Fancy larger or smaller buttons? Add size="lg" or size="sm" for additional sizes.



        <button mdbBtn type="button" gradient="peach" size="lg" mdbWavesEffect>Large Button</button>
        <button mdbBtn type="button" gradient="purple" size="lg" mdbWavesEffect>Large Button</button>

      


        <button mdbBtn type="button" gradient="peach" size="sm" mdbWavesEffect>Small Button</button>
        <button mdbBtn type="button" gradient="purple" size="sm" mdbWavesEffect>Small Button</button>
      

Create block level buttons—those that span the full width of a parent—by adding block="true".



        <button mdbBtn type="button" color="default" block="true" mdbWavesEffect>Block Button</button>
        <button mdbBtn type="button" color="light-blue" block="true" mdbWavesEffect>Block Button</button>

      

Active state

Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. There’s no need to add a class to <button>s as they use a pseudo-class. However, you can still force the same active appearance with .active (and include the aria-pressed="true" attribute) should you need to replicate the state programmatically.

Primary link Link


        <a mdbBtn role="button" color="primary" size="lg" class="active" aria-pressed="true" mdbWavesEffect>Primary
          link</a>
        <a mdbBtn role="button" color="default" size="lg" class="active" aria-pressed="true" mdbWavesEffect>Link</a>

      

Disabled state

Make buttons look inactive by adding the disabled boolean attribute to any <button> element.



        <button mdbBtn type="button" color="primary" size="lg" disabled mdbWavesEffect>Primary button</button>
        <button mdbBtn type="button" color="default" size="lg" disabled mdbWavesEffect>Button</button>

      

Button plugin

Do more with buttons. Control button states or create groups of buttons for more components like toolbars.

Toggle states

Add data-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 mdbBtn type="button" color="primary" autocomplete="off" [(ngModel)]="singleModel" mdbCheckbox
          btnCheckboxTrue="1" btnCheckboxFalse="0" mdbWavesEffect>
          Single toggle
        </button>
      

Checkbox and radio buttons

Bootstrap’s mdbBtn directive can be applied to other elements, such as <label>s, to provide checkbox or radio style button toggling. Add data-toggle="buttons" to a .btn-group containing those modified buttons to enable toggling in their respective styles.

The checked state for these buttons is only updated via click event on the button. If you use another method to update the input—e.g., with <input type="reset"> or by manually applying the input’s checked property—you’ll need to toggle .active on the <label> manually.

Note that pre-checked buttons require you to manually add the .active class to the input’s <label>.


        <!-- Checkbox -->
        <div class="btn-group">
          <label mdbBtn color="primary" [(ngModel)]="checkModel.left" mdbCheckbox mdbWavesEffect>
            Checkbox 1 (pre-checked)
          </label>
          <label mdbBtn color="primary" [(ngModel)]="checkModel.middle" mdbCheckbox mdbWavesEffect>
            Checkbox 2
          </label>
          <label mdbBtn color="primary" [(ngModel)]="checkModel.right" mdbCheckbox mdbWavesEffect>
            Checkbox 3
          </label>
        </div>

        <!-- Radio -->
        <div class="btn-group">
          <label mdbBtn color="primary" [(ngModel)]="radioModel" mdbRadio="Left" mdbWavesEffect>
            Radio 1 (pre-checked)
          </label>
          <label mdbBtn color="primary" [(ngModel)]="radioModel" mdbRadio="Middle" mdbWavesEffect>
            Radio 2
          </label>
          <label mdbBtn color="primary" [(ngModel)]="radioModel" mdbRadio="Right" mdbWavesEffect>
            Radio 3
          </label>
        </div>
      

        export class AppComponent {
          public checkModel: any = { left: true, middle: false, right: false };
          public radioModel: string = 'Left';
        }
      

Angular Buttons - API

In this section you will find informations about buttons and its required modules and available inputs, outputs, methods and events.


Modules used

In order to speed up your application, you can choose to import only the modules you actually need, instead of importing the entire MDB Angular library. Remember that importing the entire library, and immediately afterwards a specific module, is bad practice, and can cause application errors.

// MDB Angular Pro
import { ButtonsModule, WavesModule, CollapseModule } from 'ng-uikit-pro-standard'
// MDB Angular Pro
import { ButtonsModule, WavesModule, CollapseModule } from 'angular-bootstrap-md'

Inputs

MdbBtnDirective
Name Type Default Description Example
color string ' ' Allow to set color of a button. color="primary"
rounded boolean false Allow to change button style to rounded. rounded="true"
gradient string ' ' Allow to add a gradient background color to the button. gradient="peach"
outline boolean false Allow to change button style to outline. outline="true"
flat boolean false Allow to change button style to flat flat="true"
size string ' ' Allow to change size of the button. Available values are: sm, lg. size="lg"
block boolean false Allow to change button style to block. block="true"
floating boolean false Allow to change button style to floating. floating="true"