Toggle buttons

ToggleButtonControl · ButtonGroupControl · SegmentedControl

Switch options on and off, or pick one or several, from a row of buttons.

Overview

ToggleButtonControl is a Blazor toggle button: it stays pressed until clicked again, so users turn an option on or off in one click, such as a blog on a website estimate. ButtonGroupControl joins related buttons in one bar, with every option in view, for one choice or several, such as a task status or its labels. SegmentedControl shows a few text choices as one bar that works as a radio group, such as a budget per sprint or per week.

Examples

#Toggle button

Add extras to the estimate: each button stays down until pressed again, @bind-Selected holds its state, and the total follows. Core pages is Selected with Enabled false; the flag is icon-only, named with aria-label.

Website relaunch for Green Fork Cafe: extras

$24,000 estimateIncludes core pages, online ordering

#Button group

Pick one status and any labels to filter the open Sprint 8 tasks: Selection makes a group single or multiple choice, AllowEmpty lets the labels be cleared (then every label matches), QA is a disabled item, and Stack the labels sets Orientation.

Status
Labels
3 of 8 open tasks match
  • WEB-115 Navigation barFrontend
  • WEB-118 Order emailsBackend
  • WEB-123 Photo galleryFrontend

#Segmented control

Switch the Build budget between per sprint, in total and per week on one bar; the arrow keys move the choice as in a radio group.

Build milestone, 4 sprints, 8 weeks

$3,000 per sprint

Documentation

ParameterTypeDefaultDescription
SelectedboolfalsePressed state; two-way with @bind-Selected.
ChildContentRenderFragment?nullThe label: text or any markup, after the icon.
IconCssstring?nullClasses for an icon before the label, such as bi bi-journal-text.
Enabled (base)booltrueFalse disables the button and keeps its pressed look. There is no Disabled parameter.
Title (base)string?nullNative tooltip. An icon-only toggle also needs aria-label.
Visible (base)booltrueFalse hides the button with display:none.
CssClass / Style (base)string?nullOn the inner button.
Id / Tag / Data / Parent (base)nullAccepted but not rendered. A written id binds to Id, so it does not reach the button.
(unmatched attributes)Dictionary<string,object>—Passed to the inner button, such as aria-label and data-*.
An unhandled error has occurred. Reload 🗙

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 retry or reload the page.