Master Bootstrap From Scratch

Clear, interactive, and structured Bootstrap lessons designed for beginners and developers.

Bootstrap List Groups

Bootstrap List Groups provide a flexible way to display a series of related items in a clean and organized layout.

Simple Explanation: A List Group is a collection of items displayed together inside a bordered and styled container.

What is a List Group?

A List Group is a Bootstrap component used to display multiple related items as a group.

It can be used for:

  • Course topics
  • Navigation menus
  • Categories
  • User lists
  • Notifications
  • Product lists
Bootstrap provides ready-made styling, so we do not need to create all the borders and spacing manually.

Basic List Group

To create a basic List Group, use the .list-group class on the parent element and .list-group-item on every item.

Example

<ul class="list-group">

    <li class="list-group-item">
        HTML
    </li>

    <li class="list-group-item">
        CSS
    </li>

    <li class="list-group-item">
        Bootstrap
    </li>

    <li class="list-group-item">
        JavaScript
    </li>

</ul>

Output

  • HTML
  • CSS
  • Bootstrap
  • JavaScript

List Group with Links

List Groups can also be created using <a> elements.

This is useful when every list item needs to behave like a clickable link.

Example

<div class="list-group">

    <a href="#" class="list-group-item list-group-item-action">
        HTML
    </a>

    <a href="#" class="list-group-item list-group-item-action">
        CSS
    </a>

    <a href="#" class="list-group-item list-group-item-action">
        Bootstrap
    </a>

</div>

Output

.list-group-item-action makes the item interactive and provides a hover effect.

Active List Group Item

The .active class is used to highlight the currently selected or active item.

Example

<div class="list-group">

    <a href="#" class="list-group-item list-group-item-action active">
        Bootstrap
    </a>

    <a href="#" class="list-group-item list-group-item-action">
        HTML
    </a>

    <a href="#" class="list-group-item list-group-item-action">
        CSS
    </a>

</div>

Output

Disabled List Group Item

The .disabled class is used when an item should appear unavailable.

Example

<div class="list-group">

    <a href="#" class="list-group-item list-group-item-action">
        HTML
    </a>

    <a href="#"
       class="list-group-item list-group-item-action disabled">
        Advanced JavaScript
    </a>

</div>

Output

Contextual List Group Items

Bootstrap provides contextual classes to give different meanings to list items.

Common contextual classes include:

  • .list-group-item-primary
  • .list-group-item-success
  • .list-group-item-danger
  • .list-group-item-warning
  • .list-group-item-info
  • .list-group-item-light
  • .list-group-item-dark

Example

<ul class="list-group">

    <li class="list-group-item list-group-item-primary">
        Primary
    </li>

    <li class="list-group-item list-group-item-success">
        Success
    </li>

    <li class="list-group-item list-group-item-warning">
        Warning
    </li>

    <li class="list-group-item list-group-item-danger">
        Danger
    </li>

</ul>

Output

  • Primary
  • Success
  • Warning
  • Danger

List Group with Badges

A List Group can contain badges to display counts, statuses or additional information.

Example

<ul class="list-group">

    <li class="list-group-item d-flex justify-content-between align-items-center">
        HTML
        <span class="badge bg-primary rounded-pill">
            10
        </span>
    </li>

    <li class="list-group-item d-flex justify-content-between align-items-center">
        CSS
        <span class="badge bg-primary rounded-pill">
            8
        </span>
    </li>

</ul>

Output

  • HTML 10
  • CSS 8
  • Bootstrap 12

Flush List Group

The .list-group-flush class removes some outer borders and rounded corners so that the List Group can blend with its parent container.

Example

<div class="list-group list-group-flush">

    <a href="#" class="list-group-item list-group-item-action">
        HTML
    </a>

    <a href="#" class="list-group-item list-group-item-action">
        CSS
    </a>

    <a href="#" class="list-group-item list-group-item-action">
        Bootstrap
    </a>

</div>

Output

Horizontal List Group

The .list-group-horizontal class displays List Group items horizontally.

Example

<ul class="list-group list-group-horizontal">

    <li class="list-group-item">
        HTML
    </li>

    <li class="list-group-item">
        CSS
    </li>

    <li class="list-group-item">
        Bootstrap
    </li>

</ul>

Output

  • HTML
  • CSS
  • Bootstrap

CIIT Training Institute Example

Suppose CIIT Training Institute wants to display its popular courses using a Bootstrap List Group.

Real-world use: List Groups are useful for course menus, technology categories, student dashboards and training module navigation.

Important List Group Classes

Class Purpose
.list-group Creates the List Group container
.list-group-item Creates an individual List Group item
.list-group-item-action Makes an item interactive
.active Highlights the active item
.disabled Shows an unavailable item
.list-group-flush Removes outer borders and rounded corners
.list-group-horizontal Displays items horizontally
.list-group-item-primary Applies primary contextual styling
.list-group-item-success Applies success contextual styling
.list-group-item-danger Applies danger contextual styling

Common Mistakes

  • Forgetting to add .list-group to the parent.
  • Forgetting .list-group-item on individual items.
  • Using .list-group-item-action when the item is not intended to be interactive.
  • Applying .active to multiple items when only one item should be selected.
  • Using too many contextual colors and reducing readability.

Summary

  • .list-group creates a Bootstrap List Group.
  • .list-group-item creates individual items.
  • .list-group-item-action makes items interactive.
  • .active highlights the selected item.
  • .disabled displays an unavailable item.
  • .list-group-flush removes outer borders and rounded corners.
  • .list-group-horizontal displays items horizontally.
  • Contextual classes can be used to communicate different states or meanings.