Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 58 ยท Components

List Groups, Breadcrumbs and Pagination

Build Bootstrap list groups (flush, actionable, numbered), breadcrumbs with aria-current, and pagination with sizes, active and disabled states and good accessibility.

Three components handle the "where am I and what is nearby" part of an interface. List groups present a series of related items, such as settings, messages or search results. Breadcrumbs show the path from the home page to the current page. Pagination moves through long sets of results. All three are built from ordinary lists and links, which is good for accessibility, and all three are styled by a few classes.

You need no JavaScript for anything in this lesson. If you want a refresher on how lists render by default, see Typography.

List groups

A list group is a ul with the class list-group and li children with list-group-item. It gives each item padding, a border and rounded outer corners.

State and color come from modifier classes: active highlights the selected item, disabled greys it out, and list-group-item-success, list-group-item-danger and the other variants add a contextual color.

HTML
<ul class="list-group">
  <li class="list-group-item active" aria-current="true">Selected item</li>
  <li class="list-group-item">Another item</li>
  <li class="list-group-item disabled" aria-disabled="true">Disabled item</li>
</ul>

Variants

  • Flush (list-group-flush) removes the outer borders and rounded corners so the list fits edge to edge inside a card or a sidebar.
  • Numbered (list-group-numbered) uses an ol with CSS counters to prefix each item with a number.
  • Horizontal (list-group-horizontal, or list-group-horizontal-md for a breakpoint) lays the items in a row.
  • Actionable list groups use <a> or <button> elements with list-group-item-action, which add hover and focus styles. Use them when each item is a link or a control.

Items can contain anything: headings, badges, flex utilities. A common pattern is d-flex justify-content-between align-items-start with a badge on the right, as you saw in Alerts, Badges, Progress and Spinners.

List group variants

Notice how the flush list sits in the card without doubled borders; that is the reason the modifier exists. The disabled item uses aria-disabled="true" because an <a> cannot be truly disabled.

A breadcrumb trail shows the page hierarchy, for example Home > Library > Data. It helps people orient themselves and jump up a level. The markup is a nav with an aria-label="breadcrumb", holding an ol.breadcrumb. Each li has breadcrumb-item. The last item has the class active and aria-current="page" and is not a link.

HTML
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="#">Home</a></li>
    <li class="breadcrumb-item"><a href="#">Library</a></li>
    <li class="breadcrumb-item active" aria-current="page">Data</li>
  </ol>
</nav>

The separators are drawn by CSS (a "/" by default), so they are not in the HTML or read by screen readers. Change the divider with the CSS variable --bs-breadcrumb-divider, for example style="--bs-breadcrumb-divider: '>';" on the nav. Quote the value as a CSS string. To use an SVG or no divider at all, set it to ''.

An ordered list (ol) is correct because the trail has a real order. Keep labels short; on long trails you may shorten the middle part.

flowchart LR
  H["Home<br/>(link)"] --> L["Library<br/>(link)"] --> D["Data<br/>(current page, no link)"]

Every item except the last is a link, and the last carries aria-current="page".

Pagination

Pagination splits results across pages. The markup is again a nav (with an aria-label that says what is paged), a ul.pagination, and li.page-item elements containing a.page-link (or a button.page-link when JavaScript swaps content without navigation).

  • active on the li marks the current page; add aria-current="page" on its link.
  • disabled on the li greys out previous/next at the ends; for a link also add tabindex="-1" and aria-disabled="true".
  • Sizes are pagination-lg and pagination-sm on the ul.
  • Alignment uses flex utilities on the ul: justify-content-center or justify-content-end.

Provide readable names for the arrows: a << symbol alone means nothing when spoken. Use visible text such as "Previous", or put aria-label="Previous" on a link that shows only an arrow symbol and mark the symbol aria-hidden="true".

Breadcrumb and pagination that react to clicks

Bootstrap supplies only the look. The script is yours: it moves the active class, switches aria-current and disables Previous and Next at the ends. On a real site the links would go to real URLs (?page=2) and the server would render the right state.

For a very long result set, show only a window of page numbers (first, last, and a few around the current page) and use "..." for the gaps. Mark the ellipsis item disabled.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which class lets a list group sit edge to edge inside a card without outer borders?

    list-group-flush removes the outer borders and rounded corners, so it blends with the container.
  2. 2. How should the current page appear in a breadcrumb trail?

    The current page is the end of the trail; it is not a link and is marked for assistive technology.
  3. 3. When should list items use list-group-item-action?

    The action class adds hover and focus styles that signal clickable items, so it belongs on a or button elements.
  4. 4. What is the correct way to disable the Previous link in pagination?

    The li class supplies the style, and the attributes keep the link out of keyboard and assistive technology interaction.
  5. 5. How do you make pagination larger?

    pagination-lg (or pagination-sm) on the .pagination list changes the padding and font size of every page link.

Summary

  • List groups are list-group with list-group-item children; use active, disabled, -flush, -numbered, -horizontal and list-group-item-action as needed.
  • Breadcrumbs are nav[aria-label=breadcrumb] > ol.breadcrumb; the last item is active with aria-current="page" and has no link.
  • Change breadcrumb dividers with --bs-breadcrumb-divider.
  • Pagination is nav > ul.pagination > li.page-item > a.page-link; mark the current page active with aria-current, and disable ends correctly.
  • Bootstrap provides the styles only; you or your server supply the page-changing logic.

Next lesson: Accordion and Collapse.