Skip to content

List group

A bordered block of rows: a settings menu, a list of records, an activity feed, the steps of an onboarding.

items is an array of {label?, href?, active?, disabled?, variant?, title?, description?, icon?, meta?}, rendered with ListGroup:Item. Pick the element of the root with tag, for the content: nav with link items for navigation, ul or ol for a list (the generated items then render as <li>), div (the default) otherwise.

ListGroup:Item renders an <a> when href is set and a <button type="button"> when button is set (href wins when both are). Both get the hover and focus style of an actionable item (list-group-item-action). Otherwise the item is a <div>. action forces that style on or off, here off for the last link:

In a ul or ol list group, set tag="li" on each item that is not a link nor a button:

An item can be a row of slots (Tabler 1.7+): ListGroup:Media for an icon, an avatar or an input, ListGroup:Content with a ListGroup:Title and a ListGroup:Description, ListGroup:Meta for a time, a count or a badge, and ListGroup:Actions with tag="div" for buttons and other controls. Only the content slot is required: its presence turns the item into a row. The title and the description are cut with an ellipsis; add text-wrap to a ListGroup:Description for a longer text.

On ListGroup:Item, and in items, title, description, icon and meta render those slots for you, here in link items. The slots are <span>s, valid in a link, a button or a label item too (tag="div" switches one to a <div>). Each one is a block of the item (media, body, meta, then an empty actions), to replace a single slot:

selectable gives an item with a checked ListGroup:Check, a checkbox or a radio, the look of an active one, with no JavaScript (list-group-selectable, Tabler 1.7+). Use tag="label" items, so a click on the whole row changes the input:

ListGroup:Nested holds indented items right after their parent item (list-group-nested, Tabler 1.7+). collapse makes it a Bootstrap collapse, open with show, and the parent its toggle; list-group-item-toggle on the chevron turns it over while the group is open:

size makes the items compact (sm) or roomy (lg): it changes their vertical padding and the gap between the slots (list-group-sm, list-group-lg, Tabler 1.7+).

active marks the current item, with aria-current="true". disabled greys out an item the user cannot pick. A disabled link loses its href and gets aria-disabled="true" and tabindex="-1", so it cannot be followed nor focused. A disabled button gets the disabled attribute.

variant tints an item: primary secondary success danger warning info dark light.

numbered numbers the items with a CSS counter. Use it on an <ol>, so the order is in the markup too:

horizontal lays the items out in a row. As a bare attribute, the row applies at every width. With a breakpoint (sm md lg xl xxl), the items stack below it and line up from it:

flush removes the outer border and the rounded corners, so the list group sits edge to edge in a card. card gives the items the horizontal padding of the card (card-list-group). ListGroup:Header splits the list into sections, with a small uppercase label:

hoverable highlights the row under the cursor, even for plain items, and reveals its ListGroup:Actions: a link on the trailing edge of the item. show keeps the action visible, here for a user already in the favorites. Lay the item out with a grid to put the action at the end:

ListGroup:Actions is hidden with opacity only: it stays in the tab order, and keyboard users reach it without seeing it. Never make it the only way to do something, and name it with an aria-label, since it usually holds an icon only.

transparent drops the background and the borders of the items, for a side menu. It also sets a negative horizontal margin of 1.25rem, the padding of a card body: in one, the labels line up with the rest of the content and the active highlight spans the full width of the card.

ListGroup:

Prop Type Default Description
tag string 'div' div ul ol nav: the root element; generated items render as <li> in a ul or ol
items array? null Entries with the props of ListGroup:Item below, rendered with it
flush bool false No outer border nor rounded corners (list-group-flush)
hoverable bool false Highlights the row under the cursor and reveals its actions (list-group-hoverable)
transparent bool false No background nor borders on the items, for a side menu (list-group-transparent)
numbered bool false Numbers the items (list-group-numbered)
horizontal bool|string false Items in a row: true for every width, or from a breakpoint sm md lg xl xxl
card bool false Card padding on the items (card-list-group)
size string? null sm lg: compact or roomy items (list-group-sm, list-group-lg)
selectable bool false A checked ListGroup:Check marks its item active (list-group-selectable)

Other attributes go to the root <div class="list-group"> (or the tag set).

ListGroup:Item:

Prop Type Default Description
label string? null Item text
href string? null Renders an <a href>
button bool false Renders a <button type="button"> (ignored with href)
tag string 'div' div li label: the element of an item that is not a link nor a button
action bool? null Hover and focus style (list-group-item-action): true for links and buttons
active bool false Current item (active, aria-current="true")
disabled bool false Item the user cannot pick (disabled): see Active and disabled
variant string? null primary secondary success danger warning info dark light
title string? null First line of the content slot, with ListGroup:Content
description string? null Second line of the content slot, with ListGroup:Content
icon string? null Icon of the media slot, with ListGroup:Media
meta string? null Text of the meta slot, with ListGroup:Meta

Other attributes go to the <a>, <button>, <div> or <li class="list-group-item">. To drop the hover style of a link, pass action="{{ false }}" (see boolean props).

ListGroup:Header takes tag: div (the default) or li, in a ul or ol list group.

ListGroup:Actions:

Prop Type Default Description
tag string 'a' a: a link; div or span: the slot for controls of an item with slots
href string? null With tag="a", the link target, # when not set
show bool false Always visible in a hoverable list group, not only on hover (show)

Other attributes go to the <a class="list-group-item-actions"> (or the tag set).

ListGroup:Content takes title and description, ListGroup:Title an href (an <a> title, in an item that is not a link), and the slots a tag: span (the default) or div. ListGroup:Check takes type (checkbox, the default, or radio) and checked; other attributes, such as name and value, go to the <input>. ListGroup:Nested takes collapse and show.

Component Renders
ListGroup:Item <div class="list-group-item">, or an <a>, a <button> or an <li>: one row
ListGroup:Header <div class="list-group-header"> (or <li>): a section label
ListGroup:Actions <a href="#" class="list-group-item-actions">: a trailing link, shown on hover, or the actions slot
ListGroup:Media <span class="list-group-item-media">: the leading slot
ListGroup:Content <span class="list-group-item-content">: the main slot, title and description
ListGroup:Title <span class="list-group-item-title"> (or an <a>)
ListGroup:Description <span class="list-group-item-description">
ListGroup:Meta <span class="list-group-item-meta">: a time, a count or a badge
ListGroup:Check <input class="form-check-input list-group-selectable-check">
ListGroup:Nested <div class="list-group-nested">: indented items under a parent item
Block Default
content A ListGroup:Item for each entry of the items prop: replace it to compose

The content block of ListGroup:Item holds its label prop, or its slots when title, description, icon or meta is set: the media, body, meta and actions (empty) blocks. Pass children for richer content. ListGroup:Content has the title and description blocks.