List Group

Bootstrap 5 List Group component

Responsive list groups built with the latest Bootstrap 5. List groups are responsive components for displaying a series of content. A beautiful alternative to unordered lists.

List groups are a flexible and powerful component for displaying a series of content. Modify and extend them to support just about any content within.

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


Basic example

The most basic list group is an unordered list with list items and the proper classes. Build upon it with the options that follow, or with your own CSS as needed.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros

          <ul class="list-group">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
            <li class="list-group-item">Porta ac consectetur ac</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        

Active items

Add .active to a .list-group-item to indicate the current active selection.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros

          <ul class="list-group">
            <li class="list-group-item active" aria-current="true">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
            <li class="list-group-item">Porta ac consectetur ac</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        

Disabled items

Add .disabled to a .list-group-item to make it appear disabled. Note that some elements with .disabled will also require custom JavaScript to fully disable their click events (e.g., links).

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros

          <ul class="list-group">
            <li class="list-group-item disabled" aria-disabled="true">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
            <li class="list-group-item">Porta ac consectetur ac</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        


Flush

Add .list-group-flush to remove some borders and rounded corners to render list group items edge-to-edge in a parent container (e.g., cards).

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros

          <ul class="list-group list-group-flush">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
            <li class="list-group-item">Porta ac consectetur ac</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        

Numbered

Add the .list-group-numbered modifier class (and optionally use an <ol> element) to opt into numbered list group items. Numbers are generated via CSS (as opposed to a <ol>s default browser styling) for better placement inside list group items and to allow for better customization.

Numbers are generated by counter-reset on the <ol>, and then styled and placed with a ::before psuedo-element on the <li> with counter-increment and content.

  1. Cras justo odio
  2. Cras justo odio
  3. Cras justo odio

          <ol class="list-group list-group-numbered">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Cras justo odio</li>
          </ol>
        

These work great with custom content as well.

  1. Subheading
    Cras justo odio
    14
  2. Subheading
    Cras justo odio
    14
  3. Subheading
    Cras justo odio
    14

          <ol class="list-group list-group-numbered">
            <li class="list-group-item d-flex justify-content-between align-items-start">
              <div class="ms-2 me-auto">
                <div class="fw-bold">Subheading</div>
                Cras justo odio
              </div>
              <span class="badge bg-primary rounded-pill">14</span>
            </li>
            <li class="list-group-item d-flex justify-content-between align-items-start">
              <div class="ms-2 me-auto">
                <div class="fw-bold">Subheading</div>
                Cras justo odio
              </div>
              <span class="badge bg-primary rounded-pill">14</span>
            </li>
            <li class="list-group-item d-flex justify-content-between align-items-start">
              <div class="ms-2 me-auto">
                <div class="fw-bold">Subheading</div>
                Cras justo odio
              </div>
              <span class="badge bg-primary rounded-pill">14</span>
            </li>
          </ol>
        

Horizontal

Add .list-group-horizontal to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant .list-group-horizontal-{sm|md|lg|xl|xxl} to make a list group horizontal starting at that breakpoint’s min-width. Currently horizontal list groups cannot be combined with flush list groups.

ProTip: Want equal-width list group items when horizontal? Add .flex-fill to each list group item.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus

          <ul class="list-group list-group-horizontal">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
          </ul>
          <ul class="list-group list-group-horizontal-sm">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
          </ul>
          <ul class="list-group list-group-horizontal-md">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
          </ul>
          <ul class="list-group list-group-horizontal-lg">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
          </ul>
          <ul class="list-group list-group-horizontal-xl">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
          </ul>
          <ul class="list-group list-group-horizontal-xxl">
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Morbi leo risus</li>
          </ul>
        

Contextual classes

Use contextual classes to style list items with a stateful background and color.

  • Dapibus ac facilisis in
  • A simple primary list group item
  • A simple secondary list group item
  • A simple success list group item
  • A simple danger list group item
  • A simple warning list group item
  • A simple info list group item
  • A simple light list group item
  • A simple dark list group item

          <ul class="list-group">
            <li class="list-group-item">Dapibus ac facilisis in</li>

            <li class="list-group-item list-group-item-primary">
              A simple primary list group item
            </li>
            <li class="list-group-item list-group-item-secondary">
              A simple secondary list group item
            </li>
            <li class="list-group-item list-group-item-success">
              A simple success list group item
            </li>
            <li class="list-group-item list-group-item-danger">A simple danger list group item</li>
            <li class="list-group-item list-group-item-warning">
              A simple warning list group item
            </li>
            <li class="list-group-item list-group-item-info">A simple info list group item</li>
            <li class="list-group-item list-group-item-light">A simple light list group item</li>
            <li class="list-group-item list-group-item-dark">A simple dark list group item</li>
          </ul>
        

Contextual classes also work with .list-group-item-action. Note the addition of the hover styles here not present in the previous example. Also supported is the .active state; apply it to indicate an active selection on a contextual list group item.


          <div class="list-group">
            <a href="#" class="list-group-item list-group-item-action">Dapibus ac facilisis in</a>

            <a href="#" class="list-group-item list-group-item-action list-group-item-primary"
              >A simple primary list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-secondary"
              >A simple secondary list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-success"
              >A simple success list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-danger"
              >A simple danger list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-warning"
              >A simple warning list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-info"
              >A simple info list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-light"
              >A simple light list group item</a
            >
            <a href="#" class="list-group-item list-group-item-action list-group-item-dark"
              >A simple dark list group item</a
            >
          </div>
        

Conveying meaning to assistive technologies:
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.


Badges

Add badges to any list group item to show unread counts, activity, and more with the help of some flexbox utilities.

  • Cras justo odio 14
  • Dapibus ac facilisis in 2
  • Morbi leo risus 1

          <ul class="list-group">
            <li class="list-group-item d-flex justify-content-between align-items-center">
              Cras justo odio
              <span class="badge bg-primary rounded-pill">14</span>
            </li>
            <li class="list-group-item d-flex justify-content-between align-items-center">
              Dapibus ac facilisis in
              <span class="badge bg-primary rounded-pill">2</span>
            </li>
            <li class="list-group-item d-flex justify-content-between align-items-center">
              Morbi leo risus
              <span class="badge bg-primary rounded-pill">1</span>
            </li>
          </ul>
        

Custom content

Add nearly any HTML within, even for linked list groups like the one below, with the help of flexbox utilities.


          <div class="list-group">
            <a href="#" class="list-group-item list-group-item-action active" aria-current="true">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">List group item heading</h5>
                <small>3 days ago</small>
              </div>
              <p class="mb-1">
                Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus
                varius blandit.
              </p>
              <small>Donec id elit non mi porta.</small>
            </a>
            <a href="#" class="list-group-item list-group-item-action">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">List group item heading</h5>
                <small class="text-muted">3 days ago</small>
              </div>
              <p class="mb-1">
                Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus
                varius blandit.
              </p>
              <small class="text-muted">Donec id elit non mi porta.</small>
            </a>
            <a href="#" class="list-group-item list-group-item-action">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">List group item heading</h5>
                <small class="text-muted">3 days ago</small>
              </div>
              <p class="mb-1">
                Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus
                varius blandit.
              </p>
              <small class="text-muted">Donec id elit non mi porta.</small>
            </a>
          </div>
        

Checkboxes

Place Bootstrap’s checkboxes and radios within list group items and customize as needed. You can use them without <label>s, but please remember to include an aria-label attribute and value for accessibility.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros

          <ul class="list-group">
            <li class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" aria-label="..." />
              Cras justo odio
            </li>
            <li class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" aria-label="..." />
              Dapibus ac facilisis in
            </li>
            <li class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" aria-label="..." />
              Morbi leo risus
            </li>
            <li class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" aria-label="..." />
              Porta ac consectetur ac
            </li>
            <li class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" aria-label="..." />
              Vestibulum at eros
            </li>
          </ul>
        

And if you want <label>s as the .list-group-item for large hit areas, you can do that, too.


          <div class="list-group">
            <label class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" />
              Cras justo odio
            </label>
            <label class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" />
              Dapibus ac facilisis in
            </label>
            <label class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" />
              Morbi leo risus
            </label>
            <label class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" />
              Porta ac consectetur ac
            </label>
            <label class="list-group-item">
              <input class="form-check-input me-1" type="checkbox" value="" />
              Vestibulum at eros
            </label>
          </div>
        

JavaScript behavior

Use the tab JavaScript plugin to extend our list group to create tabbable panes of local content.


          <div class="row">
            <div class="col-4">
              <div class="list-group" id="list-tab" role="tablist">
                <a
                  class="list-group-item list-group-item-action active"
                  id="list-home-list"
                  data-mdb-toggle="list"
                  href="#list-home"
                  role="tab"
                  aria-controls="list-home"
                  >Home</a
                >
                <a
                  class="list-group-item list-group-item-action"
                  id="list-profile-list"
                  data-mdb-toggle="list"
                  href="#list-profile"
                  role="tab"
                  aria-controls="list-profile"
                  >Profile</a
                >
                <a
                  class="list-group-item list-group-item-action"
                  id="list-messages-list"
                  data-mdb-toggle="list"
                  href="#list-messages"
                  role="tab"
                  aria-controls="list-messages"
                  >Messages</a
                >
                <a
                  class="list-group-item list-group-item-action"
                  id="list-settings-list"
                  data-mdb-toggle="list"
                  href="#list-settings"
                  role="tab"
                  aria-controls="list-settings"
                  >Settings</a
                >
              </div>
            </div>
            <div class="col-8">
              <div class="tab-content" id="nav-tabContent">
                <div
                  class="tab-pane fade show active"
                  id="list-home"
                  role="tabpanel"
                  aria-labelledby="list-home-list"
                >
                  ...
                </div>
                <div
                  class="tab-pane fade"
                  id="list-profile"
                  role="tabpanel"
                  aria-labelledby="list-profile-list"
                >
                  ...
                </div>
                <div
                  class="tab-pane fade"
                  id="list-messages"
                  role="tabpanel"
                  aria-labelledby="list-messages-list"
                >
                  ...
                </div>
                <div
                  class="tab-pane fade"
                  id="list-settings"
                  role="tabpanel"
                  aria-labelledby="list-settings-list"
                >
                  ...
                </div>
              </div>
            </div>
          </div>
        

Fade effect

To make tabs panel fade in, add .fade to each .tab-pane. The first tab pane must also have .show to make the initial content visible.


          <div class="tab-content">
            <div class="tab-pane fade show active" id="home" role="tabpanel">...</div>
            <div class="tab-pane fade" id="profile" role="tabpanel">...</div>
            <div class="tab-pane fade" id="messages" role="tabpanel">...</div>
            <div class="tab-pane fade" id="settings" role="tabpanel">...</div>
          </div>
        

If you want to support our friends from Tailwind Elements you can also check out the Tailwind list groups documentation.

List Group - API


Usage

Using data attributes

You can activate a list group navigation without writing any JavaScript by simply specifying data-mdb-toggle="list" or on an element. Use these data attributes on .list-group-item.


          <!-- List group -->
          <div class="list-group" id="myList" role="tablist">
            <a
              class="list-group-item list-group-item-action active"
              data-mdb-toggle="list"
              href="#home"
              role="tab"
              >Home</a
            >
            <a
              class="list-group-item list-group-item-action"
              data-mdb-toggle="list"
              href="#profile"
              role="tab"
              >Profile</a
            >
            <a
              class="list-group-item list-group-item-action"
              data-mdb-toggle="list"
              href="#messages"
              role="tab"
              >Messages</a
            >
            <a
              class="list-group-item list-group-item-action"
              data-mdb-toggle="list"
              href="#settings"
              role="tab"
              >Settings</a
            >
          </div>

          <!-- Tab panes -->
          <div class="tab-content">
            <div class="tab-pane active" id="home" role="tabpanel">...</div>
            <div class="tab-pane" id="profile" role="tabpanel">...</div>
            <div class="tab-pane" id="messages" role="tabpanel">...</div>
            <div class="tab-pane" id="settings" role="tabpanel">...</div>
          </div>
        

Via JavaScript

Enable tabbable list item via JavaScript (each list item needs to be activated individually):


          const triggerTabList = [].slice.call(document.querySelectorAll('#myTab a'))
          triggerTabList.forEach((triggerEl) => {
            const tabTrigger = new mdb.Tab(triggerEl)

            triggerEl.addEventListener('click', (event) => {
              event.preventDefault()
              tabTrigger.show()
            })
          })
        

You can activate individual list item in several ways:


          const triggerEl = document.querySelector('#myTab a[href="#profile"]')
          mdb.Tab.getInstance(triggerEl).show() // Select tab by name var triggerFirstTabEl =
          document.querySelector('#myTab li:first-child a')
          mdb.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
        

Methods

Method Description
show Selects the given list item and shows its associated pane. Any other list item that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (for example, before the shown.mdb.tab event occurs).
dispose Destroys an element’s tab.
getInstance Static method which allows you to get the tab instance associated with a DOM element

          const triggerEl = document.querySelector('#trigger')
          const tab = new mdb.Tab(triggerEl);
          tab.show()
        

Events

When showing a new tab, the events fire in the following order:

  1. hide.mdb.tab (on the current active tab)
  2. show.mdb.tab (on the to-be-shown tab)
  3. hidden.mdb.tab (on the previous active tab, the same one as for the hide.mdb.tab event)
  4. shown.mdb.tab (on the newly-active just-shown tab, the same one as for the show.mdb.tab event)

If no tab was already active, the hide.mdb.tab and hidden.mdb.tab events will not be fired.

Event type Description
show.mdb.tab This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown.mdb.tab This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
hide.mdb.tab This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
hidden.mdb.tab This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.

          const tabEl = document.querySelector('a[data-mdb-toggle="list"]')
          tabEl.addEventListener('shown.mdb.tab', function (event) {
            event.target // newly activated tab
            event.relatedTarget // previous active tab
          })
        

Import

MDB UI KIT also works with module bundlers. Use the following code to import this component:


        import { Tab } from 'mdb-ui-kit';