Showcase

Blazor Button Group

The Blazor Bootstrap button group components join buttons into groups and toolbars, and turn sets of toggle buttons into radio and checkbox inputs. The examples below cover links, mixed styles, outlined styles, radio toggle buttons and checkbox toggle buttons.
API Documentation
INFO
The button group components follow the Bootstrap 5.3 button group. ButtonGroup and ButtonToolbar lay out existing Button, Dropdown, and InputGroup components. RadioButtonGroup and CheckboxButtonGroup are form inputs: they bind one value or a set of values, and work inside an EditForm.
WARNING
Every group and toolbar needs an accessible name. Set AriaLabel, or set aria-labelledby to the id of a visible label. Without one, screen readers announce only "group" or "toolbar".

Basic usage #

Join a series of buttons on a single line.
How to use:
  1. Add ButtonGroup and place Button components inside it.
  2. Set AriaLabel to describe what the buttons do together.
This demo picks a text alignment.
A group can join link buttons as well as buttons.
How to use:
  1. Use Button with Type="ButtonType.Link" and To.
  2. Mark the link to the current page with Class="active" and aria-current="page".
This demo links to related demos; the current page is active.

Mixed styles #

Each button keeps its own color.
How to use:
  1. Set a different Color on each Button.
This demo records a review decision.

Outlined styles #

Outlined buttons join the same way.
How to use:
  1. Set Outline="true" on each Button.
  2. Give icon-only buttons an aria-label.
This demo shows text formatting buttons.

Radio toggle buttons #

Pick one value from a set of toggle buttons.
How to use:
  1. Add RadioButtonGroup with @bind-Value and an AriaLabel.
  2. Add one ButtonGroupItem per choice, with its Value and Text (or child content).
  3. Set Color and Outline on the group for every button, or on an item to override it.
  4. Set Disabled on an item, or on the group to disable every item.
This demo picks a billing period and a chart range. The value type comes from the binding: string and int here.

Checkbox toggle buttons #

Pick any number of values from a set of toggle buttons.
How to use:
  1. Add CheckboxButtonGroup with @bind-Values bound to an IEnumerable<TValue> property, and an AriaLabel.
  2. Add one ButtonGroupItem per choice.
This demo filters tasks by status, using an enum as the value type.

Button toolbar #

Combine groups, and input groups, into a toolbar.
How to use:
  1. Add ButtonToolbar with an AriaLabel, and place ButtonGroup and InputGroup components inside it.
  2. Space the groups with margin utilities such as Class="me-2", or spread them with Class="justify-content-between" on the toolbar.
This demo shows a pagination toolbar, an editor toolbar with an input group, and a table toolbar.

Sizing #

Size every button in a group at once, nested groups included.
How to use:
  1. Set Size to ButtonGroupSize.Small or ButtonGroupSize.Large on the group.
  2. Do not size the individual buttons inside the group.
This demo shows large, default, and small groups (the small one with a nested dropdown), and a large radio group.

Nesting #

Put a dropdown inside a group.
How to use:
  1. Place a Dropdown inside ButtonGroup.
  2. Set Class="btn-group", role="group", and an aria-label on the Dropdown, so it joins the group as a nested group.
This demo shows message actions with a "More" menu.

Vertical variation #

Stack the buttons vertically.
How to use:
  1. Set Vertical="true" on ButtonGroup, RadioButtonGroup, or CheckboxButtonGroup.
  2. Split button dropdowns are not supported in a vertical group, as in Bootstrap; use a regular dropdown.
This demo shows vertical buttons, a vertical group with a dropdown, and a vertical radio group.

EditForm validation #

Toggle button groups take part in an EditForm like other inputs.
How to use:
  1. Bind the group to a model property inside an EditForm.
  2. Add a ValidationMessage for the property after the group.
  3. Name the group by its visible label with aria-labelledby.
Submit the empty form to see both messages. Invalid groups get the invalid class, and their inputs get 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.