List group

Source: https://getbootstrap.com/docs/6.0/components/list-group

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.

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.

<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>

</ul>`} />

Active items

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

&lt;li class="list-group-item active" aria-current="true">An active item&lt;/li>
&lt;li class="list-group-item">A second item&lt;/li>
&lt;li class="list-group-item">A third item&lt;/li>
&lt;li class="list-group-item">A fourth item&lt;/li>
&lt;li class="list-group-item">And a fifth one&lt;/li>

</ul>`} />

Use <a>s or <button>s to create actionable list group items with hover, disabled, and active states by adding .list-group-item-action. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like <li>s or <div>s) don’t provide a click or tap affordance.

Make .list-group-item-action instances appear disabled by adding .disabled, and aria-disabled="true" to inform assistive technologies that the element is disabled. You may require additional JavaScript to fully disable links and buttons.

Be sure to not use the standard .btn classes here.

&lt;a href="#" class="list-group-item list-group-item-action active" aria-current="true">
  The current link item
&lt;/a>
&lt;a href="#" class="list-group-item list-group-item-action">A second link item&lt;/a>
&lt;a href="#" class="list-group-item list-group-item-action">A third link item&lt;/a>
&lt;a href="#" class="list-group-item list-group-item-action">A fourth link item&lt;/a>
&lt;a href="#" class="list-group-item list-group-item-action disabled" aria-disabled="true">A disabled link item&lt;/a>

</div>`} />

With <button>s, you can also make use of the disabled attribute instead of the .disabled class. Sadly, <a>s don’t support the disabled attribute.

&lt;button type="button" class="list-group-item list-group-item-action active" aria-current="true">
  The current button
&lt;/button>
&lt;button type="button" class="list-group-item list-group-item-action">A second button item&lt;/button>
&lt;button type="button" class="list-group-item list-group-item-action">A third button item&lt;/button>
&lt;button type="button" class="list-group-item list-group-item-action">A fourth button item&lt;/button>
&lt;button type="button" class="list-group-item list-group-item-action" disabled>A disabled button item&lt;/button>

</div>`} />

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).

&lt;li class="list-group-item">An item&lt;/li>
&lt;li class="list-group-item">A second item&lt;/li>
&lt;li class="list-group-item">A third item&lt;/li>
&lt;li class="list-group-item">A fourth item&lt;/li>
&lt;li class="list-group-item">And a fifth one&lt;/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 pseudo-element on the <li> with counter-increment and content.

&lt;li class="list-group-item">A list item&lt;/li>
&lt;li class="list-group-item">A list item&lt;/li>
&lt;li class="list-group-item">A list item&lt;/li>

</ol>`} />

These work great with custom content as well.

&lt;li class="list-group-item d-flex justify-content-between align-items-start">
  &lt;div class="ms-2 me-auto">
    &lt;div class="fw-bold">Subheading&lt;/div>
    Content for list item
  &lt;/div>
  &lt;span class="badge theme-primary">14&lt;/span>
&lt;/li>
&lt;li class="list-group-item d-flex justify-content-between align-items-start">
  &lt;div class="ms-2 me-auto">
    &lt;div class="fw-bold">Subheading&lt;/div>
    Content for list item
  &lt;/div>
  &lt;span class="badge theme-primary">14&lt;/span>
&lt;/li>
&lt;li class="list-group-item d-flex justify-content-between align-items-start">
  &lt;div class="ms-2 me-auto">
    &lt;div class="fw-bold">Subheading&lt;/div>
    Content for list item
  &lt;/div>
  &lt;span class="badge theme-primary">14&lt;/span>
&lt;/li>

</ol>`} />

Horizontal

Add .list-group-horizontal to change the layout of list group items from vertical to horizontal across all container sizes. Alternatively, choose a responsive variant .{sm|md|lg|xl|2xl}:list-group-horizontal to make a list group horizontal starting at that breakpoint’s width.

The responsive variants use container queries, so wrap the list group in a query container—add the .contains-inline utility to a parent element—for them to take effect. 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.

<Example class="vstack gap-3" code={getData('breakpoints').map((breakpoint) => &lt;div class="contains-inline"> &lt;ul class="list-group ${breakpoint.abbr}list-group-horizontal"> &lt;li class="list-group-item">An item&lt;/li> &lt;li class="list-group-item">A second item&lt;/li> &lt;li class="list-group-item">A third item&lt;/li> &lt;/ul> &lt;/div>)} />

Drag the handle to resize the container below and watch the list group switch between vertical and horizontal layouts as the container—not the viewport—crosses the md breakpoint.

&lt;ul class="list-group md:list-group-horizontal">
  &lt;li class="list-group-item">An item&lt;/li>
  &lt;li class="list-group-item">A second item&lt;/li>
  &lt;li class="list-group-item">A third item&lt;/li>
&lt;/ul>

</div>`} />

Variants

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

<Example code={[ &lt;ul class="list-group"> &lt;li class="list-group-item">A simple default list group item&lt;/li>, ...getData('theme-colors').map((themeColor) => <li class="list-group-item theme-${themeColor.name}">A simple ${themeColor.name} list group item</li>), </ul> ]} />

Contextual classes also work with .list-group-item-action for <a> and <button> elements. 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.

<Example code={[ &lt;div class="list-group"> &lt;a href="#" class="list-group-item list-group-item-action">A simple default list group item&lt;/a>, ...getData('theme-colors').map((themeColor) => <a href="#" class="list-group-item list-group-item-action theme-${themeColor.name}">A simple ${themeColor.name} list group item</a>), </div> ]} />

With badges

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

&lt;li class="list-group-item d-flex justify-content-between align-items-center">
  A list item
  &lt;span class="badge theme-primary">14&lt;/span>
&lt;/li>
&lt;li class="list-group-item d-flex justify-content-between align-items-center">
  A second list item
  &lt;span class="badge theme-primary">2&lt;/span>
&lt;/li>
&lt;li class="list-group-item d-flex justify-content-between align-items-center">
  A third list item
  &lt;span class="badge theme-primary">1&lt;/span>
&lt;/li>

</ul>`} />

Custom content

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

&lt;a href="#" class="list-group-item list-group-item-action active" aria-current="true">
  &lt;div class="d-flex w-100 justify-content-between">
    &lt;h5 class="mb-1">List group item heading&lt;/h5>
    &lt;small>3 days ago&lt;/small>
  &lt;/div>
  &lt;p class="mb-1">Some placeholder content in a paragraph.&lt;/p>
  &lt;small>And some small print.&lt;/small>
&lt;/a>
&lt;a href="#" class="list-group-item list-group-item-action">
  &lt;div class="d-flex w-100 justify-content-between">
    &lt;h5 class="mb-1">List group item heading&lt;/h5>
    &lt;small class="fg-2">3 days ago&lt;/small>
  &lt;/div>
  &lt;p class="mb-1">Some placeholder content in a paragraph.&lt;/p>
  &lt;small class="fg-2">And some muted small print.&lt;/small>
&lt;/a>
&lt;a href="#" class="list-group-item list-group-item-action">
  &lt;div class="d-flex w-100 justify-content-between">
    &lt;h5 class="mb-1">List group item heading&lt;/h5>
    &lt;small class="fg-2">3 days ago&lt;/small>
  &lt;/div>
  &lt;p class="mb-1">Some placeholder content in a paragraph.&lt;/p>
  &lt;small class="fg-2">And some muted small print.&lt;/small>
&lt;/a>

</div>`} />

Checkboxes and radios

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.

&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="checkbox" value="" id="firstCheckbox" class="check">
    &lt;label for="firstCheckbox">First checkbox&lt;/label>
  &lt;/div>
&lt;/li>
&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="checkbox" value="" id="secondCheckbox" class="check">
    &lt;label for="secondCheckbox">Second checkbox&lt;/label>
  &lt;/div>
&lt;/li>
&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="checkbox" value="" id="thirdCheckbox" class="check">
    &lt;label for="thirdCheckbox">Third checkbox&lt;/label>
  &lt;/div>
&lt;/li>

</ul>`} />

&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="radio" name="listGroupRadio" value="" id="firstRadio" class="radio" checked>
    &lt;label for="firstRadio">First radio&lt;/label>
  &lt;/div>
&lt;/li>
&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="radio" name="listGroupRadio" value="" id="secondRadio" class="radio">
    &lt;label for="secondRadio">Second radio&lt;/label>
  &lt;/div>
&lt;/li>
&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="radio" name="listGroupRadio" value="" id="thirdRadio" class="radio">
    &lt;label for="thirdRadio">Third radio&lt;/label>
  &lt;/div>
&lt;/li>

</ul>`} />

You can use .stretched-link on <label>s to make the whole list group item clickable.

&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="checkbox" value="" id="firstCheckboxStretched" class="check">
    &lt;label class="stretched-link" for="firstCheckboxStretched">First checkbox&lt;/label>
  &lt;/div>
&lt;/li>
&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="checkbox" value="" id="secondCheckboxStretched" class="check">
    &lt;label class="stretched-link" for="secondCheckboxStretched">Second checkbox&lt;/label>
  &lt;/div>
&lt;/li>
&lt;li class="list-group-item">
  &lt;div class="form-field">
    &lt;input type="checkbox" value="" id="thirdCheckboxStretched" class="check">
    &lt;label class="stretched-link" for="thirdCheckboxStretched">Third checkbox&lt;/label>
  &lt;/div>
&lt;/li>

</ul>`} />

CSS

Variables

JavaScript behavior

Use the Tab plugin to create tabbable list group panes.