Tags & Chips

Bootstrap Tags & Chips

Note: We are transitioning MDB4 to a legacy version and focusing on developing MDB5. While we'll continue to support for the transition period, we encourage you to migrate to MDB5. We're offering a huge discount on MDB5 PRO to help with your transition, enabling you to leverage the full potential of the latest version. You can find more information here.
upgrade with discount

Bootstrap tags and chips categorize content with the use of text and icons. Tags and chips make it easier to browse throughout articles, comments or pages.

Their main goal is to provide your visitors with an intuitive way of getting what they want. Just consider, how convenient it is to find all the articles related to web development just by using a web development tag.


Basic example

Chips can be used to represent small blocks of information. They are most commonly used either for contacts or for tags.

        
            

        <div class="chip">
          <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-6.webp" alt="Contact Person"> John Doe
        </div>
    
        <div class="chip">
          Tag 220
          <i class="close fas fa-times"></i>
        </div>

      
        
    

Contacts

To create a contact chip just add an img inside.

        
            

        <div class="chip">
          <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-6.webp" alt="Contact Person"> John Doe
        </div>

      
        
    

Tags

To create a tag chip just add a close icon inside with the classclose.

        
            
    
        <div class="chip">
          Tag 220
          <i class="close fas fa-times"></i>
        </div>

      
        
    

Tags with avatars MDB Pro component

Contact Person John Doe
Contact Person Anna Smith
Contact Person Lara Lim
Contact Person Tom Dark
Contact Person Kate Horwitz
Contact Person Danny Clark
        
            

          <div class="chip">
            <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-6.webp" alt="Contact Person"> John Doe
          </div>

          <div class="chip chip-md">
            <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-10.webp" alt="Contact Person"> Anna Smith
          </div>

          <div class="chip chip-lg">
            <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-5.webp" alt="Contact Person"> Lara Lim
          </div>

        
        
    
        
            

          .chip.chip-md {
          height: 42px;
          line-height: 42px;
          border-radius: 21px;
          }
          .chip.chip-md img {
          height: 42px;
          width: 42px;
          }

          .chip.chip-lg {
          height: 52px;
          line-height: 52px;
          border-radius: 26px;
          }
          .chip.chip-lg img {
          height: 52px;
          width: 52px;
          }

        
        
    

Tags without avatars MDB Pro component

Tag 1
Tag 2
Tag 3
Tag 4
Tag 5
Tag 6
Tag 220
Tag 219
Tag 218
Tag 217
Tag 216
Tag 215
        
            

          <div class="chip pink lighten-4">
            Tag 220
            <i class="close fas fa-times"></i>
          </div>

        
        
    

Colorful tags MDB Pro component

MDB has hundreds of colors to use within chips. Take a look here to know all the possibilities.

Contact Person Caroline Smith
Contact Person Adam Grey
Contact Person Danny Moore
Contact Person Daisy Sun
Contact Person Martha Lores
Contact Person Alexandra Deyn
Contact Person Olaf Horwitz
Contact Person Mary-Kate Dare
Contact PersonThe Sylvester
Martha
Agnes
Caroline
Elisa
Francesca
25.09.2017
24.08.2016
23.07.2015
22.06.2014
Aqua color
Peach color
Purple color
Blue color
        
            

          <div class="chip blue lighten-4">
            <img src="https://mdbootstrap.com/img/Photos/Avatars/img(7).webp" alt="Contact Person"> Caroline Smith
          </div>

          <div class="chip chip-md cyan darken-2 white-text">
            <img src="https://mdbootstrap.com/img/Photos/Avatars/img(28).webp" alt="Contact Person"> Martha Lores
          </div>

          <div class="chip chip-lg success-color white-text">
            <img src="https://mdbootstrap.com/img/Photos/Avatars/img(21).webp" alt="Contact Person">The Sylvester
          </div>

          <div class="chip teal lighten-2 white-text">
            Martha
            <i class="close fas fa-times"></i>
          </div>

          <div class="chip chip-md indigo lighten-4 indigo-text">
            24.08.2016
            <i class="close fas fa-times"></i>
          </div>

          <div class="chip chip-lg aqua-gradient white-text">
            Aqua color
            <i class="close fas fa-times"></i>
          </div>

        
        
    
        
            

.chip.chip-md {
    height: 42px;
    line-height: 42px;
    border-radius: 21px;
}

.chip.chip-md img {
    height: 42px;
    width: 42px;
}

.chip.chip-md .close {
    height: 42px;
    line-height: 42px;
    border-radius: 21px;
}

.chip.chip-lg {
    height: 52px;
    line-height: 52px;
    border-radius: 26px;
}

.chip.chip-lg img {
    height: 52px;
    width: 52px;
}

.chip.chip-lg .close {
    height: 52px;
    line-height: 52px;
    border-radius: 26px;
}

        
        
    

Javascript usage MDB Pro component

Adding tags

Type a name and press enter to add a tag. Click X to remove it.

        
            

          <div class="chips chips-placeholder"></div>

        
        
    
        
            

          $(document).ready(function() {

            $('.chips-placeholder').materialChip({
              placeholder: 'Enter a tag',
              secondaryPlaceholder: '+Tag',
            });
          })

        
        
    

Set initial tags

        
            

          <div class="chips chips-initial"></div>

        
        
    
        
            

          $(document).ready(function() {

            $('.chips-initial').materialChip({
              data: [{
                tag: 'Tag 1',
              }, {
                tag: 'Tag 2',
              }, {
                tag: 'Tag 3',
              }],
            });
          })

        
        
    

Chip data object

        
            
          
          var chip = {
            tag: 'chip content',
            image: '', //optional
            id: 1, //optional
          };

        
        
    

Tags with autocomplete MDB Pro component"

MDB Chips allows you to use autocomplete with chips and automatically saved data on change to selected array. You can set data easly from js file or from a server.

        
            

          <div class="container my-5">
            <div id="chips-autocomplete-test" class="chips chips-placeholder chips-autocomplete"></div>
          </div>

        
        
    
        
            

          <script>
            let states = [
              "Alabama",
              "Alaska",
              "Arizona",
              "Arkansas",
              "California",
              "Colorado",
              "Connecticut",
              "Delaware",
              "Florida",
              "Georgia",
              "Hawaii",
              "Idaho",
              "Illnois",
              "Indiana",
              "Iowa",
              "Kansas",
              "Kentucky",
              "Louisiana",
              "Maine",
              "Maryland",
              "Massachusetts",
              "Michigan",
              "Minnesota",
              "Mississippi",
              "Missouri",
              "Montana",
              "Nebraska",
              "Nevada",
              "New Hampshire",
              "New Jersey",
              "New Mexico",
              "New York",
              "North Carolina",
              "North Dakota",
              "Ohio",
              "Oklahoma",
              "Oregon",
              "Pennsylvania",
              "Rhode Island",
              "South Carolina",
              "South Dakota",
              "Tennessee",
              "Texas",
              "Utah",
              "Vermont",
              "Virginia",
              "Washington",
              "West Virginia",
              "Wisconsin",
              "Wyoming"
            ];

            $(document).ready(() => {
              $('#chips-autocomplete-test').materialChip({
                placeholder: 'Enter a tag',
                secondaryPlaceholder: '+Tag',
                dataChip: states
              });
            })
          </script>

        
        
    
        
            

          <script>
            $.ajax({
              url: 'your-path-to-file/test.json',

              success: data => data
            });

            $(document).ready(() => {
              $('#chips-autocomplete-test').materialChip({
                placeholder: 'Enter a tag',
                secondaryPlaceholder: '+Tag',
                dataChip: x.responseJSON.states
              });
            })
          </script>

          {
            "states": [
              "Alabama",
              "Alaska",
              "Arizona",
              "Arkansas",
              "California",
              "Colorado",
              "Connecticut",
              "Delaware",
              "Florida",
              "Georgia",
              "Hawaii",
              "Idaho",
              "Illnois",
              "Indiana",
              "Iowa",
              "Kansas",
              "Kentucky",
              "Louisiana",
              "Maine",
              "Maryland",
              "Massachusetts",
              "Michigan",
              "Minnesota",
              "Mississippi",
              "Missouri",
              "Montana",
              "Nebraska",
              "Nevada",
              "New Hampshire",
              "New Jersey",
              "New Mexico",
              "New York",
              "North Carolina",
              "North Dakota",
              "Ohio",
              "Oklahoma",
              "Oregon",
              "Pennsylvania",
              "Rhode Island",
              "South Carolina",
              "South Dakota",
              "Tennessee",
              "Texas",
              "Utah",
              "Vermont",
              "Virginia",
              "Washington",
              "West Virginia",
              "Wisconsin",
              "Wyoming"
            ]
          }

        
        
    

jQuery Plugin Options

Option Name Type Description
data array Set the chip data (look at the Chip data object)
placeholder string Set the first placeholder when there are no tags.
secondaryPlaceholder string Set the second placeholder when adding additional tags.

Events

Event Description
chips.add This method is triggered when a chip is added
chips.delete This method is triggered when a chip is deleted.
chips.select This method is triggered when a chip is selected
        
            

          $('.chips').on('chip.add', function(e, chip){
            // you have the added chip here
          });

          $('.chips').on('chip.delete', function(e, chip){
            // you have the deleted chip here
          });

          $('.chips').on('chip.select', function(e, chip){
            // you have the selected chip here
          });

        
        
    

Methods

Parameter Description
data This returns the stored data
options This returns the given options
        
            

          $('.chips-initial').materialChip('data');
          $('.chips-initial').materialChip('options');