Skip to content
Related Articles

Related Articles

How to make Tabs using Angular UI Bootstrap ?

Improve Article
Save Article
  • Last Updated : 17 Jun, 2021
Improve Article
Save Article

In this article we will see how to make Tabs using Angular UI bootstrap. Angular UI Bootstrap is an Angular JS framework created by Angular UI developers for providing better UI which can be used easily.

Download AngularUI from the link:

https://angular-ui.github.io/bootstrap

Approach: 

  • First, add Angular UI bootstrap scripts needed for your project.

<script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js”></script>
<script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js”></script>
<script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js”></script>
<script src=”https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js”></script>

  • Make tab with its UIBootStrap classes which will set the UI look for the tab.
  • Now make different types of tab using different classes and run the code.

 

Example 1: Making tabs with justified content.

HTML




<!DOCTYPE html>
<html ng-app="gfg">
  <head>
  
    <!-- Adding CDN scripts required for our page -->
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <link href=
          rel="stylesheet">
    <script>
      // Adding Modules
      angular.module('gfg', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);
      angular.module('gfg').controller('tab', function ($scope) {
      });
    </script>
  </head>
  
  <body>
    <div ng-controller="tab" 
         style="padding: 10px; margin: 10px; border-style: double;">
      <!-- making a tab -->
      <uib-tabset active="activeJustified" justified="true">
        <uib-tab index="0" heading="Column-1">
          Column-1 Content
        </uib-tab>
        <uib-tab index="1" heading="Column-2">
          Column-2 Content
        </uib-tab>
        <uib-tab index="2" heading="Column-3">
          Column-3 Content
        </uib-tab>
      </uib-tabset>
    </div>
  </body>
</html>


Output:

Example 2:

HTML




<!DOCTYPE html>
<html ng-app="gfg">
  <head>
  
    <!-- Adding CDN scripts required for our page -->
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <link href=
          rel="stylesheet">
  
    <script>
      // Adding Modules
      angular.module('gfg', ['ngAnimate', 'ngSanitize', 'ui.bootstrap']);
      angular.module('gfg').controller('tab', function ($scope) {
      });
    </script>
  </head>
  
  <body>
    <div ng-controller="tab" 
         style="padding: 10px; margin: 10px; border-style: double;">
        <!-- making a tab -->
        <uib-tabset active="activePill" vertical="true" type="pills">
            <uib-tab index="0" heading="Row-1">
              Row-1 Content
          </uib-tab>
            <uib-tab index="1" heading="Row-2">
              Row-2 Content
          </uib-tab>
            <uib-tab index="2" heading="Row-3">
              Row-3 Content
          </uib-tab>
        </uib-tabset>
    </div>
  </body>
</html>


Output:

Reference: https://angular-ui.github.io/bootstrap/#!#Tabs


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!