Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Forms

TwToggleGroup

TwToggleGroup is a set of toggle buttons with single or multiple selection, for alignment, view modes or filters. Bind Value or Values, or set Multiple.

Last updated 9 November 2026

Single selection

By default one item can be pressed at a time. Bind it with @bind-Value; each TwToggleGroupItem sets the Value it stands for.
Alignment: left
RAZOR
<div class="flex flex-col items-start gap-3">
    <TwToggleGroup @bind-Value="alignment" AriaLabel="Text alignment">
        <TwToggleGroupItem Value="@("left")" Icon="Icon.Text_Left" AriaLabel="Align left" />
        <TwToggleGroupItem Value="@("center")" Icon="Icon.Text_Center" AriaLabel="Align center" />
        <TwToggleGroupItem Value="@("right")" Icon="Icon.Text_Right" AriaLabel="Align right" />
        <TwToggleGroupItem Value="@("justify")" Icon="Icon.Justify" AriaLabel="Justify" />
    </TwToggleGroup>
    <span class="text-sm">Alignment: @alignment</span>
</div>
CSHARP
@code {
    private string? alignment = "left";
}

Multiple selection

Set Multiple to let any number of items be pressed, and bind them with @bind-Values.
Formatting: bold
RAZOR
<div class="flex flex-col items-start gap-3">
    <TwToggleGroup Multiple @bind-Values="formatting" AriaLabel="Text formatting">
        <TwToggleGroupItem Value="@("bold")" Icon="Icon.Type_Bold" AriaLabel="Bold" />
        <TwToggleGroupItem Value="@("italic")" Icon="Icon.Type_Italic" AriaLabel="Italic" />
        <TwToggleGroupItem Value="@("underline")" Icon="Icon.Type_Underline" AriaLabel="Underline" />
    </TwToggleGroup>
    <span class="text-sm">Formatting: @(formatting.Any() ? string.Join(", ", formatting) : "none")</span>
</div>
CSHARP
@code {
    private IEnumerable<string> formatting = ["bold"];
}

Deselectable

A single-select group keeps its selection, like a radio group. Set Deselectable so pressing the pressed item releases it, leaving none pressed.
Rating: none
RAZOR
<div class="flex flex-col items-start gap-3">
    <TwToggleGroup @bind-Value="rating" Deselectable AriaLabel="Rating">
        <TwToggleGroupItem Value="@("up")" Icon="Icon.Hand_Thumbs_Up" AriaLabel="Helpful" />
        <TwToggleGroupItem Value="@("down")" Icon="Icon.Hand_Thumbs_Down" AriaLabel="Not helpful" />
    </TwToggleGroup>
    <span class="text-sm">Rating: @(rating ?? "none")</span>
</div>
CSHARP
@code {
    private string? rating;
}

Variants

ToggleVariant.Text (the default) sets the items on a filled bar. ToggleVariant.Outlined draws a border around the group instead.
RAZOR
<div class="flex flex-wrap items-center gap-4">
    <TwToggleGroup Value="@("grid")" AriaLabel="View (filled bar)">
        <TwToggleGroupItem Value="@("grid")" Icon="Icon.Grid" Label="Grid" />
        <TwToggleGroupItem Value="@("list")" Icon="Icon.List_Ul" Label="List" />
    </TwToggleGroup>
    <TwToggleGroup Value="@("grid")" Variant="ToggleVariant.Outlined" AriaLabel="View (outlined)">
        <TwToggleGroupItem Value="@("grid")" Icon="Icon.Grid" Label="Grid" />
        <TwToggleGroupItem Value="@("list")" Icon="Icon.List_Ul" Label="List" />
    </TwToggleGroup>
</div>

Sizes

Set Size on the group to size every item.
RAZOR
<div class="flex flex-wrap items-center gap-4">
    <TwToggleGroup Size="Size.Sm" Multiple Values="@(new[] { "bold" })" AriaLabel="Small formatting">
        <TwToggleGroupItem Value="@("bold")" Icon="Icon.Type_Bold" AriaLabel="Bold" />
        <TwToggleGroupItem Value="@("italic")" Icon="Icon.Type_Italic" AriaLabel="Italic" />
    </TwToggleGroup>
    <TwToggleGroup Size="Size.Md" Multiple Values="@(new[] { "bold" })" AriaLabel="Medium formatting">
        <TwToggleGroupItem Value="@("bold")" Icon="Icon.Type_Bold" AriaLabel="Bold" />
        <TwToggleGroupItem Value="@("italic")" Icon="Icon.Type_Italic" AriaLabel="Italic" />
    </TwToggleGroup>
    <TwToggleGroup Size="Size.Lg" Multiple Values="@(new[] { "bold" })" AriaLabel="Large formatting">
        <TwToggleGroupItem Value="@("bold")" Icon="Icon.Type_Bold" AriaLabel="Bold" />
        <TwToggleGroupItem Value="@("italic")" Icon="Icon.Type_Italic" AriaLabel="Italic" />
    </TwToggleGroup>
</div>

Colors

Set Color on the group to tint every pressed item, or on a TwToggleGroupItem to tint just that one.
RAZOR
<TwToggleGroup Multiple Values="@(new[] { "wifi", "bluetooth" })" Color="Color.Primary" Variant="ToggleVariant.Outlined" AriaLabel="Connections">
    <TwToggleGroupItem Value="@("wifi")" Icon="Icon.Wifi" Label="Wi-Fi" />
    <TwToggleGroupItem Value="@("bluetooth")" Icon="Icon.Bluetooth" Label="Bluetooth" />
    <TwToggleGroupItem Value="@("airplane")" Icon="Icon.Airplane" Label="Flight mode" Color="Color.Warning" />
</TwToggleGroup>

Vertical

Set Vertical to stack the items. The arrow keys work in either direction.
RAZOR
<TwToggleGroup Value="@("week")" Vertical AriaLabel="Calendar view">
    <TwToggleGroupItem Value="@("day")" Label="Day" />
    <TwToggleGroupItem Value="@("week")" Label="Week" />
    <TwToggleGroupItem Value="@("month")" Label="Month" />
</TwToggleGroup>

Disabled

Set Disabled on the group to disable every item, or on a TwToggleGroupItem to disable just that one. The arrow keys skip disabled items.
RAZOR
<div class="flex flex-wrap items-center gap-4">
    <TwToggleGroup Value="@("left")" Disabled AriaLabel="Alignment (disabled)">
        <TwToggleGroupItem Value="@("left")" Icon="Icon.Text_Left" AriaLabel="Align left" />
        <TwToggleGroupItem Value="@("center")" Icon="Icon.Text_Center" AriaLabel="Align center" />
    </TwToggleGroup>
    <TwToggleGroup Value="@("left")" AriaLabel="Alignment (one disabled)">
        <TwToggleGroupItem Value="@("left")" Icon="Icon.Text_Left" AriaLabel="Align left" />
        <TwToggleGroupItem Value="@("center")" Icon="Icon.Text_Center" AriaLabel="Align center" Disabled />
        <TwToggleGroupItem Value="@("right")" Icon="Icon.Text_Right" AriaLabel="Align right" />
    </TwToggleGroup>
</div>

View mode selector

Bind an enum to switch between views of the same content.
Report.pdf
Budget.xlsx
Photo.jpg
Notes.txt
Slides.pptx
Logo.svg
RAZOR
<div class="flex flex-col gap-4">
    <TwToggleGroup @bind-Value="view" AriaLabel="View">
        <TwToggleGroupItem Value="ViewMode.Grid" Icon="Icon.Grid" Label="Grid" />
        <TwToggleGroupItem Value="ViewMode.List" Icon="Icon.List_Ul" Label="List" />
    </TwToggleGroup>
    <div class="@(view == ViewMode.Grid ? "grid grid-cols-3 gap-2" : "flex flex-col gap-2")">
        @foreach (var file in files)
        {
            <div class="rounded-lg border border-[oklch(21%_0.006_285.885)]/15 dark:border-[oklch(97.807%_0.029_256.847)]/15 p-3 text-sm">@file</div>
        }
    </div>
</div>
CSHARP
@code {
    private enum ViewMode { List, Grid }
    
    private ViewMode view = ViewMode.Grid;
    
    private readonly string[] files = ["Report.pdf", "Budget.xlsx", "Photo.jpg", "Notes.txt", "Slides.pptx", "Logo.svg"];
}

Accessibility

A single-select group is a radiogroup of radio items with aria-checked, following the WAI-ARIA radio group pattern: moving to an item with the arrow keys also selects it. A Multiple group is a group of toggle buttons with aria-pressed, following the toolbar pattern: the arrow keys move focus and Space or Enter presses the focused item. Either way the group is a single Tab stop, and Arrow Left and Arrow Right swap in a right to left layout. Name the group with AriaLabel or AriaLabelledBy, and give icon-only items an AriaLabel.

Keyboard navigation

The group is a single Tab stop, and disabled items are skipped. In a single-select group moving to an item also selects it; in a Multiple group the arrow keys only move focus. In a right to left layout Arrow Left moves to the next item and Arrow Right to the previous one.
Key What it does
Tab Moves focus into the group, onto the pressed item of a single-select group, or the item that last had focus, or the first item.
Arrow Right or Arrow Down Moves to the next item. From the last item it wraps to the first.
Arrow Left or Arrow Up Moves to the previous item. From the first item it wraps to the last.
Home or End Moves to the first or last item.
Enter or Space Presses or releases the focused item.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwToggleTheme), configured via the AddTwBlazor() options callback described on the Get Started page. Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.

Inherited from TwToggle - this component reuses that theme rather than defining its own.

Property Type Controls
ToggleRounded Rounded?
DefaultVariant ToggleVariant?
Base string
Sm string
Md string
Lg string
IconSm string
IconMd string
IconLg string
Unpressed string
Hover string
Pressed string
GroupPressed string
PressedForcedColors string
Outlined string
Disabled string
GroupBase string
GroupHorizontal string
GroupVertical string
GroupText string
GroupOutlined string

Global Theme Configuration

These reuse shared design tokens configured once on TwBlazorTheme, rather than being unique to this component.
Property Type Controls
Colors TwBlazorPalette

Full reference: TwToggleTheme on the API docs.

On this page

  • Single selection
  • Multiple selection
  • Deselectable
  • Variants
  • Sizes
  • Colors
  • Vertical
  • Disabled
  • View mode selector
  • Accessibility
  • Keyboard navigation
  • Theme configuration
twblazor

The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

Discord (opens in a new tab) GitHub(opens in a new tab)

Get started

  • Install guide
  • Theming
  • Class merging
  • Localization

Guides

  • Tailwind CSS with Blazor
  • Why twblazor?
  • Right to left
  • AI agents and skills

Resources

  • API documentation (opens in a new tab)
  • llms.txt (opens in a new tab)
  • MIT License (opens in a new tab)

Community

  • Contributing (opens in a new tab)
  • Code of conduct (opens in a new tab)
  • Report an issue (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload