Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

A view switch

Use a group for a view switch, where the pressed button takes the solid fill and the rest stay outline.

Day, week and month
Show code
<app-button-group label="Range">
    <app-button variant="Outline" aria-pressed="false">Day</app-button>
    <app-button aria-pressed="true">Week</app-button>
    <app-button variant="Outline" aria-pressed="false">Month</app-button>
</app-button-group>

Vertical stack

Stack the buttons top to bottom when the row is too narrow or the group sits in a side panel.

Stacked range buttons
Show code
<app-button-group label="Range" size="Sm" vertical="true">
    <app-button variant="Outline">Day</app-button>
    <app-button variant="Outline">Week</app-button>
</app-button-group>

Full width

Fill the container when the buttons are a row of equal choices, sharing its width equally.

Buttons sharing one row
Show code
<app-button-group label="Text style" full-width="true">
    <app-button variant="Outline">Bold</app-button>
    <app-button variant="Outline">Italic</app-button>
    <app-button variant="Outline">Underline</app-button>
</app-button-group>

Every option

Every value of every prop, one cell each.

label

label: names the group for screen readers, no visual change

children

children: the app-button elements inside the group (React: children)

size

size="sm"
size="md" (default)
size="lg"

vertical

vertical="false" (default)
vertical="true"

full-width

full-width="false" (default)
full-width="true"

class

class: extra classes on the group (React: className)

Guidance

What to do, and what to avoid.

Use it when

  • Two to five related actions: text styles, bulk actions, a view switch.
  • A toolbar section that should read as one control.

Reach for something else when

  • Choosing one of a few options. → AppSegmented
  • A main action with a few alternatives. → AppSplitButton

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

sm md lg
React, generated from the controls
<AppButtonGroup label="Text style">
  <AppButton variant="outline">Bold</AppButton>
  <AppButton variant="outline">Italic</AppButton>
  <AppButton variant="outline">Underline</AppButton>
</AppButtonGroup>
Razor, the same props
<app-button-group label="Text style">
    <app-button variant="Outline">Bold</app-button>
    <app-button variant="Outline">Italic</app-button>
    <app-button variant="Outline">Underline</app-button>
</app-button-group>

4 props. The 4 most used come first.

Used on most screens 4 props

PropTypeDefaultDescription
labeldefault - string - Accessible name for the group ("Text style").
sizedefault md sm | md | lg md One size for every button in the group.
verticaldefault false bool false Stack the buttons top to bottom.
full-widthdefault false bool false Fill the container, the buttons sharing the row equally.

Screen reader

2 notes
  • The group has role group and is announced by its label.
  • Each button is still its own tab stop: a button group is a set of actions, not a single-choice control.