WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Bootstrap List Groups


In this chapter we discuss List Groups

Basic List Groups

There are following basic list group is an unordered list with list items:

  • I am First item
  • I am Second item
  • I am Third item

To create a basic list group, use an <ul> element with class .list-group, and <li> elements with class .list-group-item:

Example

<ul class="list-group">
  <li class="list-group-item">I am First item</li>
  <li class="list-group-item">I am Second item</li>
  <li class="list-group-item">I am Third item</li>
</ul>
Try it Yourself »

List Group With Badges

We can add badges to a list group. The badges have position on the right:

  • 10I am New
  • 8I am Deleted
  • 2I am Warnings

To create a badge, create a <span> element with class .badge inside the list item:

Example

<ul class="list-group">
  <li class="list-group-item"><span class="badge">10</span>I am New</li>
  <li class="list-group-item"><span class="badge">8</span>I am Deleted</li>
  <li class="list-group-item"><span class="badge">2</span> I am Warnings</li>
</ul>
Try it Yourself »

List Group With Linked Items

The items in a list group can also be hyperlinks is href. then you can add background color on hover:

You can create a list group with linked items, use <div> instead of <ul> and <a> instead of <li>:

Example

<div class="list-group">
  <a href="#" class="list-group-item">I am First item</a>
  <a href="#" class="list-group-item">I am Second item</a>
  <a href="#" class="list-group-item">I am Third item</a>
</div>
Try it Yourself »

Active State

Use the .active class to highlight the current item:

Example

<div class="list-group">
  <a href="#" class="list-group-item active">First item</a>
  <a href="#" class="list-group-item">Second item</a>
  <a href="#" class="list-group-item">Third item</a>
</div>
Try it Yourself »

Disabled Item

The following list group has a disabled item:

To disable an item, add the .disabled class:

Example

<div class="list-group">
  <a href="#" class="list-group-item disabled">I am First item</a>
  <a href="#" class="list-group-item">I am Second item</a>
  <a href="#" class="list-group-item">I am Third item</a>
</div>
Try it Yourself »

Contextual Classes

Contextual classes can be used to color list items:

  • I am First item
  • I am Second item
  • I am Third item
  • I am Fourth item

The classes for coloring list-items are: .list-group-item-success, list-group-item-info, list-group-item-warning, and .list-group-item-danger:

Example

<ul class="list-group">
  <li class="list-group-item list-group-item-success">I am First item</li>
  <li class="list-group-item list-group-item-info">I am Second item</li>
  <li class="list-group-item list-group-item-warning">I am Third item</li>
  <li class="list-group-item list-group-item-danger">I am Fourth item</li>
</ul>
Try it Yourself »

Custom Content

We can add nearly any HTML inside a list group item.

Bootstrap 3 support the classes .list-group-item-heading and .list-group-item-text which can be used as follows:

Example

<div class="list-group">
  <a href="#" class="list-group-item active">
    <h4 class="list-group-item-heading">I am First List Group Item Heading</h4>
    <p class="list-group-item-text">I am List Group Item Text</p>
  </a>
  <a href="#" class="list-group-item">
    <h4 class="list-group-item-heading">I am Second List Group Item Heading</h4>
    <p class="list-group-item-text">I am List Group Item Text</p>
  </a>
  <a href="#" class="list-group-item">
    <h4 class="list-group-item-heading">I am Third List Group Item Heading</h4>
    <p class="list-group-item-text">List Group Item Text</p>
  </a>
</div>
Try it Yourself »