Tabs

Angular Bootstrap 5 Tabs component

tabs are quasi-navigation components which can highly improve website clarity and increase user experience.

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


Basic example

Tab 1 content
Tab 2 content
Tab 3 content
        
            
            <mdb-tabs>
              <mdb-tab title="Tab 1">Tab content 1</mdb-tab>
              <mdb-tab title="Tab 2">Tab content 2</mdb-tab>
              <mdb-tab title="Tab 3">Tab content 3</mdb-tab>
            </mdb-tabs>
          
        
    

Fill and justify

Force your tabs contents to extend the full available width using following settings.

Fill

To proportionately fill all available space, use [fill]="true" input. Notice that all horizontal space is occupied, but not every nav item has the same width.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
              <mdb-tabs [fill]="true">
                <mdb-tab title="Tab 1">Tab content 1</mdb-tab>
                <mdb-tab title="Tab 2">Tab content 2</mdb-tab>
                <mdb-tab title="Tab 3">Tab content 3</mdb-tab>
              </mdb-tabs>
            
        
    

Justify

For equal-width elements, use [justified]="true" input. All horizontal space will be occupied by nav links, but unlike the [fill]="true" above, every nav item will be the same width.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
              <mdb-tabs [justified]="true">
                <mdb-tab title="Link">Tab content 1</mdb-tab>
                <mdb-tab title="Very very very very long link">Tab content 2</mdb-tab>
                <mdb-tab title="Another link">Tab content 3</mdb-tab>
              </mdb-tabs>
            
        
    

Vertical

Use [vertical]="true" input to change the layout direction.

Home content
Profile content
Messages content
        
            
            <mdb-tabs [vertical]="true">
              <mdb-tab title="Home">Home content</mdb-tab>
              <mdb-tab title="Profile">Profile content</mdb-tab>
              <mdb-tab title="Messages">Messages content</mdb-tab>
            </mdb-tabs>
          
        
    

Custom title template

If you need to add a title that is more complex than simple string, use ng-template with mdbTabTitle directive.

        
            
            <mdb-tabs>
              <mdb-tab>
                <ng-template mdbTabTitle>
                  <span><i class="fab fa-lg fa-mdb me-2"></i> Tab 1</span>
                </ng-template>
                Tab content 1
              </mdb-tab>
              <mdb-tab>
                <ng-template mdbTabTitle>
                  <span><i class="fab fa-lg fa-mdb me-2"></i> Tab 2</span>
                </ng-template>
                Tab content 2
              </mdb-tab>
              <mdb-tab>
                <ng-template mdbTabTitle>
                  <span><i class="fab fa-lg fa-mdb me-2"></i> Tab 3</span>
                </ng-template>
                Tab content 3
              </mdb-tab>
            </mdb-tabs>
          
        
    

Tabs with icons

Use one of 1541 icons and add it to the tabs. See the icon docs to explore all the available icons.

Tab 1 content
Tab 2 content
Tab 3 content
        
            
            <mdb-tabs>
              <mdb-tab>
                <ng-template mdbTabTitle
                  ><span><i class="fas fa-chart-pie fa-fw me-2"></i>Sales</span></ng-template
                >
                Tab content 1
              </mdb-tab>
              <mdb-tab>
                <ng-template mdbTabTitle
                  ><span><i class="fas fa-chart-line fa-fw me-2"></i>Subscriptions</span></ng-template
                >
                Tab content 2
              </mdb-tab>
              <mdb-tab>
                <ng-template mdbTabTitle
                  ><span><i class="fas fa-cogs fa-fw me-2"></i>Settings</span></ng-template
                >
                Tab content 3
              </mdb-tab>
            </mdb-tabs>
            
        
    

Lazy loading

You can use ng-template with mdbTabContent directive to lazy load tab content. The content will be loaded only when tab is activated.

        
            
            <mdb-tabs>
              <mdb-tab title="Tab 1">
                <ng-template mdbTabContent> Tab content 1 </ng-template>
              </mdb-tab>
              <mdb-tab title="Tab 2">
                <ng-template mdbTabContent> Tab content 2 </ng-template>
              </mdb-tab>
              <mdb-tab title="Tab 3">
                <ng-template mdbTabContent> Tab content 3 </ng-template>
              </mdb-tab>
            </mdb-tabs>
          
        
    

Tabs - API


Import

        
            
          import { MdbTabsModule } from 'mdb-angular-ui-kit/tabs';
          …
          @NgModule ({
            ...
            imports: [MdbTabsModule],
            ...
          })
        
        
    

Inputs

MdbTabComponent

Name Type Default Description
disabled boolean false Disables the specific tab.
title string '' Changes title of the tab.
fade boolean true Defines whether the fade animation on tab change should occur or not.

MdbTabsComponent

Name Type Default Description
fill boolean false Forces tabs content to extend the full available width.
justified boolean false Makes all tabs equal width and forces them to take full available width.
pills boolean false Changes to pills layout.
vertical boolean false Changes to vertical layout.

Outputs

Name Type Description
activeTabChange EventEmitter<MdbTabChange> Event fired when active tab changes.
        
            
              <mdb-tabs (activeTabChange)="onTabChange($event)">
                <mdb-tab title="Tab 1">Tab content 1</mdb-tab>
                <mdb-tab title="Tab 2">Tab content 2</mdb-tab>
                <mdb-tab title="Tab 3">Tab content 3</mdb-tab>
              </mdb-tabs>
            
        
    
        
            
            import { Component } from '@angular/core';
            import { MdbTabChange } from 'mdb-angular-ui-kit/tabs';
            
            @Component({
              selector: 'app-root',
              templateUrl: './app.component.html',
              styleUrls: ['./app.component.scss'],
            })
            export class AppComponent {
              onTabChange(event: MdbTabChange): void {
                console.log(event);
              }
            }            
            
        
    

Methods

Name Description Example
setActiveTab(index: number) Set desired tab as active tabs.setActiveTab(1)
        
            
              <mdb-tabs #tabs>
                <mdb-tab title="Tab 1">Tab content 1</mdb-tab>
                <mdb-tab title="Tab 2">Tab content 2</mdb-tab>
                <mdb-tab title="Tab 3">Tab content 3</mdb-tab>
              </mdb-tabs>
            
        
    
        
            
            import { AfterViewInit, Component, ViewChild } from '@angular/core';
            import { MdbTabsComponent } from 'mdb-angular-ui-kit/tabs';
            
            @Component({
              selector: 'app-root',
              templateUrl: './app.component.html',
              styleUrls: ['./app.component.scss'],
            })
            export class AppComponent implements AfterViewInit {
              @ViewChild('tabs') tabs!: MdbTabsComponent;
            
              ngAfterViewInit(): void {
                setTimeout(() => {
                  this.tabs.setActiveTab(1);
                }, 0);
              }
            }                
            
        
    

Advanced types

MdbTabChange

        
            
          class MdbTabChange {
            index: number;
            tab: MdbTabComponent;
          }
          
        
    

CSS variables

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

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

        
            
        // .nav
        --#{$prefix}nav-link-disabled-color: #{$nav-link-disabled-color};

        // .nav-tabs
        --#{$prefix}nav-tabs-border-width: #{$nav-tabs-border-width};
        --#{$prefix}nav-tabs-border-color: #{$nav-tabs-border-color};
        --#{$prefix}nav-tabs-border-radius: #{$nav-tabs-border-radius};
        --#{$prefix}nav-tabs-link-hover-border-color: #{$nav-tabs-link-hover-border-color};
        --#{$prefix}nav-tabs-link-active-bg: #{$nav-tabs-link-active-bg};
        
        // .nav-tabs
        // .nav-link
        --#{$prefix}nav-tabs-link-font-weight: #{$nav-tabs-link-font-weight};
        --#{$prefix}nav-tabs-link-font-size: #{$nav-tabs-link-font-size};
        --#{$prefix}nav-tabs-link-color: #{$nav-tabs-link-color};
        --#{$prefix}nav-tabs-link-padding-top: #{$nav-tabs-link-padding-top};
        --#{$prefix}nav-tabs-link-padding-bottom: #{$nav-tabs-link-padding-bottom};
        --#{$prefix}nav-tabs-link-padding-x: #{$nav-tabs-link-padding-x};
        --#{$prefix}nav-tabs-link-hover-bgc: #{$nav-tabs-link-hover-bgc};
        --#{$prefix}nav-tabs-link-border-bottom-width: #{$nav-tabs-link-border-bottom-width};
        --#{$prefix}nav-tabs-link-active-color: #{$nav-tabs-link-active-color};
        --#{$prefix}nav-tabs-link-active-border-color: #{$nav-tabs-link-active-border-color};
        
        
    

SCSS variables

        
            
        $nav-link-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
          border-color 0.15s ease-in-out;
        $nav-link-disabled-color: $gray-600;
        
        $nav-tabs-border-color: $gray-300;
        $nav-tabs-border-width: $border-width;
        $nav-tabs-border-radius: $border-radius;
        $nav-tabs-link-hover-border-color: $gray-200 $gray-200 $nav-tabs-border-color;
        $nav-tabs-link-active-color: $gray-700;
        $nav-tabs-link-active-bg: $body-bg;
        $nav-tabs-link-active-border-color: $gray-300 $gray-300 $nav-tabs-link-active-bg;

        $nav-tabs-link-border-bottom-width: 2px;
        $nav-tabs-link-font-weight: 500;
        $nav-tabs-link-font-size: 12px;
        $nav-tabs-link-padding-top: 17px;
        $nav-tabs-link-padding-bottom: 16px;
        $nav-tabs-link-padding-x: 29px;
        $nav-tabs-link-hover-background-color: hsl(0, 0%, 96%);
        $nav-tabs-link-active-color: $primary;
        $nav-tabs-link-active-border-color: $primary;

        $nav-tabs-link-color: rgba(0, 0, 0, 0.55);
        $nav-tabs-link-hover-bgc: #f7f7f7;