mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-03 15:24:19 +01:00
f228802fd0
- Overhauls the states, including the link/button variants, for list groups to better match how we handle .btn states. - Moved the .list-group-item-action styles before the .list-group-item so that we don't have to do as much overriding. - Removed the plain-hover-focus mixins from the disabled and active states since they're unnecessary. - Added support for :active states on the .list-group-item-action variant (for the current click state). - Removed the heading and text classes and variables since we can accomplish the same thing with utilities. - Added support for :disabled on the .list-group-item-action as well since we can use those with button elements. - Rearranged docs to reflect all the above changes. - Reformatted some Sass variables.
145 lines
5.9 KiB
Markdown
145 lines
5.9 KiB
Markdown
---
|
|
layout: docs
|
|
title: List group
|
|
description: Learn about Bootstrap's list group component for rendering series of related content.
|
|
group: components
|
|
---
|
|
|
|
List groups are a flexible and powerful component for displaying a series of content. List group items can be modified and extended to support just about any content within. They can also be used as navigation with the right modifier class.
|
|
|
|
## Contents
|
|
|
|
* Will be replaced with the ToC, excluding the "Contents" header
|
|
{:toc}
|
|
|
|
## 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.
|
|
|
|
{% example html %}
|
|
<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>
|
|
{% endexample %}
|
|
|
|
## Active items
|
|
|
|
Add `.active` to a `.list-group-item` to indicate the current active selection.
|
|
|
|
{% example html %}
|
|
<ul class="list-group">
|
|
<li class="list-group-item active">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>
|
|
{% endexample %}
|
|
|
|
## 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).
|
|
|
|
{% example html %}
|
|
<ul class="list-group">
|
|
<li class="list-group-item disabled">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>
|
|
{% endexample %}
|
|
|
|
## Links and buttons
|
|
|
|
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.
|
|
|
|
Be sure to **not use the standard `.btn` classes here**.
|
|
|
|
{% example html %}
|
|
<div class="list-group">
|
|
<a href="#" class="list-group-item active">
|
|
Cras justo odio
|
|
</a>
|
|
<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">Morbi leo risus</a>
|
|
<a href="#" class="list-group-item list-group-item-action">Porta ac consectetur ac</a>
|
|
<a href="#" class="list-group-item list-group-item-action disabled">Vestibulum at eros</a>
|
|
</div>
|
|
{% endexample %}
|
|
|
|
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.
|
|
|
|
{% example html %}
|
|
<div class="list-group">
|
|
<button type="button" class="list-group-item list-group-item-action active">
|
|
Cras justo odio
|
|
</button>
|
|
<button type="button" class="list-group-item list-group-item-action">Dapibus ac facilisis in</button>
|
|
<button type="button" class="list-group-item list-group-item-action">Morbi leo risus</button>
|
|
<button type="button" class="list-group-item list-group-item-action">Porta ac consectetur ac</button>
|
|
<button type="button" class="list-group-item list-group-item-action" disabled>Vestibulum at eros</button>
|
|
</div>
|
|
{% endexample %}
|
|
|
|
## Contextual classes
|
|
|
|
Use contextual classes to style list items, default or linked. Also includes `.active` state.
|
|
|
|
{% example html %}
|
|
<div class="list-group">
|
|
<a href="#" class="list-group-item list-group-item-action list-group-item-success">Dapibus ac facilisis in</a>
|
|
<a href="#" class="list-group-item list-group-item-action list-group-item-info">Cras sit amet nibh libero</a>
|
|
<a href="#" class="list-group-item list-group-item-action list-group-item-warning">Porta ac consectetur ac</a>
|
|
<a href="#" class="list-group-item list-group-item-action list-group-item-danger">Vestibulum at eros</a>
|
|
</div>
|
|
{% endexample %}
|
|
|
|
{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %}
|
|
{{ callout-include | markdownify }}
|
|
|
|
## With badges
|
|
|
|
Add badges to any list group item to show unread counts, activity, and more with the help of some utilities. Note the [`justify-content-between` utility class]({{ site.baseurl }}/layout/grid/#horizontal-alignment) and the badge's placement.
|
|
|
|
{% example html %}
|
|
<ul class="list-group">
|
|
<li class="list-group-item justify-content-between">
|
|
Cras justo odio
|
|
<span class="badge badge-default badge-pill">14</span>
|
|
</li>
|
|
<li class="list-group-item justify-content-between">
|
|
Dapibus ac facilisis in
|
|
<span class="badge badge-default badge-pill">2</span>
|
|
</li>
|
|
<li class="list-group-item justify-content-between">
|
|
Morbi leo risus
|
|
<span class="badge badge-default badge-pill">1</span>
|
|
</li>
|
|
</ul>
|
|
{% endexample %}
|
|
|
|
## Custom content
|
|
|
|
Add nearly any HTML within, even for linked list groups like the one below.
|
|
|
|
{% example html %}
|
|
<div class="list-group">
|
|
<a href="#" class="list-group-item list-group-item-action active">
|
|
<h5 class="mt-0 mb-1">List group item heading</h5>
|
|
<small>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</small>
|
|
</a>
|
|
<a href="#" class="list-group-item list-group-item-action">
|
|
<h5 class="mt-0 mb-1">List group item heading</h5>
|
|
<small>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</small>
|
|
</a>
|
|
<a href="#" class="list-group-item list-group-item-action">
|
|
<h5 class="mt-0 mb-1">List group item heading</h5>
|
|
<small>Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</small>
|
|
</a>
|
|
</div>
|
|
{% endexample %}
|