Showcase

Blazor List Group

The Blazor Bootstrap ListGroup component shows a list of items, links, or buttons, with single, multiple, checkbox, or radio selection, or tabs that switch content panes. The examples below cover links and buttons, flush, numbered, horizontal and colors.
API Documentation
INFO
ListGroup follows the Bootstrap 5.3 list group. Use ListGroupItem children (static mode), or set Data (data-bound mode). Set TItem to the type of the item values; a static list without selection still sets it, for example TItem="string".

Basic usage #

A list of items, with an optional active item.
How to use:
  1. Add ListGroup with TItem, and ListGroupItem children.
  2. Set Active="true" on the current item; it is marked aria-current="true".
Make items actionable with a link or a click handler; they get hover, focus, and active styles.
How to use:
  1. Set Href for a link, or OnClick for a button.
  2. Set Disabled="true". A disabled link has no href, is marked aria-disabled="true", and does not navigate; a disabled button uses the native disabled attribute.

Flush #

Remove the outer borders and rounded corners so the list sits edge to edge, for example in a card.
How to use:
  1. Set Flush="true". It is ignored when Horizontal is set.

Numbered #

Number the items. The list renders as an ordered list.
How to use:
  1. Set Numbered="true". Items can hold custom content, such as a heading and a badge.

Horizontal #

Lay the items out in a row at every width, or from a breakpoint up.
How to use:
  1. Set Horizontal="true", and HorizontalBreakpoint to Small through ExtraExtraLarge (default Always).
Resize the window to see each list switch from a column to a row.

Colors #

Give an item a contextual color. Actionable items also get matching hover and active styles.
How to use:
  1. Set Color on ListGroupItem.
  2. Do not rely on color alone to carry meaning; also say it in the text.

Badges #

Add a badge to an item, for example a count.
How to use:
  1. Put a Badge in the item, and lay it out with Class="d-flex justify-content-between align-items-center".

Custom content #

Put any markup inside an item, including links.
This demo shows a notification panel; the newest notification is active.

Checkboxes and radios #

Give each item a real checkbox or radio input with a label.
How to use:
  1. Set SelectionMode to Checkbox and bind @bind-SelectedItems, or to Radio and bind @bind-SelectedItem.
  2. Set Value on each item. The item content is the input's label; set AriaLabel when an item has no visible text.
  3. Set StretchedLink="true" to make the whole row clickable.

Single selection #

Select one item. The list is a listbox: items are options with aria-selected, and a check mark shows the selected item.
How to use:
  1. Set SelectionMode="ListGroupSelectionMode.Single", bind @bind-SelectedItem, and set an AriaLabel.
  2. Keyboard: Tab moves into the list, the arrow keys, Home, and End move between items, and Space or Enter selects.

Multiple selection #

Select any number of items. The listbox is marked aria-multiselectable="true".
How to use:
  1. Set SelectionMode="ListGroupSelectionMode.Multiple" and bind @bind-SelectedItems. Space or Enter toggles the focused item.

Disabled #

Disable the whole list, or single items.
How to use:
  1. Set Disabled="true" on the group, Disabled on a static item, or DisabledSelector for data-bound items.

Data binding #

Render items from data.
How to use:
  1. Set Data and TextField.
  2. Set OnItemClick to make the items buttons that report the clicked item.

Templates #

Render data-bound items with your own markup.
How to use:
  1. Set ItemTemplate; it takes precedence over TextField.
This demo combines a template with checkbox selection.

Tabs #

Use the items as tabs that switch content panes.
How to use:
  1. Set TabMode="true", and add a ListGroupTabPane per section with a unique Name, and a Title or TitleTemplate.
  2. Panes fade by default; set Fade="false" to switch instantly. Set TabListClass and TabContentClass to change the two columns.
  3. Handle OnShowing, OnShown, OnHiding, and OnHidden, and call ShowTabAsync to switch from code.
  4. Keyboard: the arrow keys move between tabs and show them.
  5. Panes can be added or removed with @if; their tabs keep the markup order and raise the same events.

EditForm validation #

Selectable lists take part in an EditForm like other inputs.
Submit the empty form to see both messages. An invalid list gets the invalid class and aria-invalid="true".

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.