跳到主要内容

List groups

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

结果
Loading...
实时编辑器

Active items

Set the active prop to indicate the list groups current active selection.

结果
Loading...
实时编辑器

Disabled items

Set the disabled prop to prevent actions on a <ListGroup.Item>. For elements that aren't naturally disable-able (like anchors) onClick handlers are added that call preventDefault to mimick disabled behavior.

结果
Loading...
实时编辑器

Actionable items

Toggle the action prop to create actionable list group items, with disabled, hover and active styles. List item actions will render a <button> or <a> (depending on the presence of an href) by default but can be overridden by setting the as prop as usual.

List items actions are distinct from plain items to ensure that click or tap affordances aren't applied to non-interactive items.

结果
Loading...
实时编辑器

Flush

Add the flush variant to remove outer borders and rounded corners to render list group items edge-to-edge in a parent container such as a Card.

结果
Loading...
实时编辑器

Numbered

Add the numbered prop 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.

结果
Loading...
实时编辑器

These work great with custom content as well.

结果
Loading...
实时编辑器

Horizontal

Use the horizontal prop to make the ListGroup render horizontally. Currently horizontal list groups cannot be combined with flush list groups.

结果
Loading...
实时编辑器

There are responsive variants to horizontal: setting it to {sm|md|lg|xl|xxl} makes the list group horizontal starting at that breakpoint’s min-width.

结果
Loading...
实时编辑器

Contextual classes

Use contextual variants on <ListGroup.Item>s to style them with a stateful background and color.

结果
Loading...
实时编辑器

When paired with actions, additional hover and active styles apply.

结果
Loading...
实时编辑器

Tabbed Interfaces

You can also use the [Tab][tabs] components to create ARIA compliant tabbable interfaces with the <ListGroup> component. Swap out the <Nav> component for the list group and you are good to go.

结果
Loading...
实时编辑器

API

ListGroup

ListGroupItem