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

TwRadioButton

TwRadioButton is a Blazor radio button component. Bind SelectedValue, set Color, Disabled and Horizontal, or generate a group from Items.

Last updated 18 October 2026

Basic usage

Group radio buttons with TwRadioGroup and bind values with @bind-SelectedValue.
Shipping method

Selected: standard

RAZOR
<TwRadioGroup T="string" Legend="Shipping method" Name="shipping">
    <TwRadioButton Value="@("standard")" Label="Standard (3-5 days)" @bind-SelectedValue="shipping" Color="Color.Success" />
    <TwRadioButton Value="@("express")" Label="Express (1-2 days)" @bind-SelectedValue="shipping" Color="Color.Success" />
    <TwRadioButton Value="@("overnight")" Label="Overnight" @bind-SelectedValue="shipping" Color="Color.Success" />
</TwRadioGroup>
<p class="mt-4 text-sm text-gray-600 dark:text-white">Selected: <strong>@shipping</strong></p>
CSHARP
@code {
    private string shipping = "standard";
}

Colors

TwRadioButton supports all the standard theme colors via the Color property.
RAZOR
@foreach (Color c in ((Color[])Enum.GetValues(typeof(Color))))
{
    @if (c != Color.Light && c != Color.Dark)
    {
        <div class="block mt-2">
            <div class="p-3">
                <TwRadioButton Label="@c.ToString()" Value="true" Color="c" SelectedValue="true" />
            </div>
        </div>
    }
    else
    {
        <div class="block mt-2">
            <div class="@(c == Color.Light ? "bg-gray-900 p-3 rounded-lg" : "bg-white p-3 rounded-lg")">
                <TwRadioButton Label="@c.ToString()" Value="true" Color="c" LabelClass="@(c == Color.Light ? "text-white dark:text-white" : "text-gray-900 dark:text-gray-900")" AriaLabel="@($"{@c.ToString()} radio button")" SelectedValue="true" />
            </div>
        </div>
    }
}

Data-driven (automatic)

Use Items and @bind-Value to generate radio buttons from a list.
Select a size

Selected: medium

Rate your experience

Rating: 3 / 5

RAZOR
<div class="mb-6">
    <TwRadioGroup Legend="Select a size"
                  Items="@_sizeItems"
                  Name="auto-size"
                  @bind-Value="selectedSize"
                  ItemColor="Color.Primary" />
    <p class="mt-4 text-sm text-gray-600 dark:text-white">Selected: <strong>@selectedSize</strong></p>
</div>

<div>
    <TwRadioGroup Legend="Rate your experience"
                  Items="@_ratingItems"
                  Name="rating"
                  @bind-Value="rating"
                  ItemColor="Color.Accent" />
    <p class="mt-4 text-sm text-gray-600 dark:text-white">Rating: <strong>@rating / 5</strong></p>
</div>
CSHARP
@code {
    private string selectedSize = "medium";
    private int rating = 3;
    
    private readonly List<RadioGroupItem<string>> _sizeItems = new()
    {
        new() { Label = "Small", Value = "small" },
        new() { Label = "Medium", Value = "medium" },
        new() { Label = "Large", Value = "large" },
        new() { Label = "Extra Large", Value = "xl" }
    };
    
    private readonly List<RadioGroupItem<int>> _ratingItems = new()
    {
        new() { Label = "⭐ Poor", Value = 1 },
        new() { Label = "⭐⭐ Fair", Value = 2 },
        new() { Label = "⭐⭐⭐ Good", Value = 3 },
        new() { Label = "⭐⭐⭐⭐ Great", Value = 4 },
        new() { Label = "⭐⭐⭐⭐⭐ Excellent", Value = 5 }
    };
}

Horizontal layout & custom spacing

Use Horizontal to arrange buttons side-by-side, or Class="gap-4" for custom spacing.
Payment method

Selected: credit

Billing cycle

Selected: monthly

RAZOR
<div class="mb-6">
    <TwRadioGroup Legend="Payment method"
                  Items="@_paymentItems"
                  Name="payment"
                  @bind-Value="payment"
                  ItemColor="Color.Primary"
                  Horizontal />
    <p class="mt-4 text-sm text-gray-600 dark:text-white">Selected: <strong>@payment</strong></p>
</div>

<TwRadioGroup T="string" Legend="Billing cycle" Name="billing" Class="gap-6">
    <TwRadioButton Value="@("monthly")" Label="Monthly" @bind-SelectedValue="billing" Color="Color.Accent" />
    <TwRadioButton Value="@("yearly")" Label="Yearly (Save 20%)" @bind-SelectedValue="billing" Color="Color.Accent" />
</TwRadioGroup>
<p class="mt-4 text-gray-600 dark:text-white">Selected: <strong>@billing</strong></p>
CSHARP
@code {
    private string payment = "credit";
    private string billing = "monthly";
    
    private readonly List<RadioGroupItem<string>> _paymentItems = new()
    {
        new() { Label = "Credit Card", Value = "credit" },
        new() { Label = "PayPal", Value = "paypal" },
        new() { Label = "Cryptocurrency", Value = "crypto" }
    };
}

Disabled state

Disable the entire group with the Disabled property.
Premium plan (Disabled)
RAZOR
<TwRadioGroup T="string" Legend="Premium plan (Disabled)" Name="plan" Disabled>
    <TwRadioButton Value="@("basic")" Label="Basic - £9/month" SelectedValue="@("basic")" Color="Color.Accent" />
    <TwRadioButton Value="@("pro")" Label="Pro - £29/month" SelectedValue="@("basic")" Color="Color.Accent" />
    <TwRadioButton Value="@("enterprise")" Label="Enterprise - £99/month" SelectedValue="@("basic")" Color="Color.Accent" />
</TwRadioGroup>

Programmatic control

Change the selection programmatically by updating the bound value.
Subscription plan

Current plan: free

RAZOR
<TwRadioGroup Legend="Subscription plan"
              Items="@_planItems"
              Name="dynamic-plan"
              @bind-Value="dynamicPlan"
              ItemColor="Color.Accent" />

<div class="flex gap-2 mt-4">
    <TwButton Label="Free" Color="Color.Primary" Variant="ButtonVariant.Outlined" OnClick="@(() => dynamicPlan = "free")" />
    <TwButton Label="Basic" Color="Color.Primary" Variant="ButtonVariant.Outlined" OnClick="@(() => dynamicPlan = "basic")" />
    <TwButton Label="Pro" Color="Color.Accent" Variant="ButtonVariant.Outlined" OnClick="@(() => dynamicPlan = "pro")" />
</div>

<p class="mt-4 text-sm text-gray-600 dark:text-white">Current plan: <strong>@dynamicPlan</strong></p>
CSHARP
@code {
    private string dynamicPlan = "free";
    
    private readonly List<RadioGroupItem<string>> _planItems = new()
    {
        new() { Label = "Free - £0/month", Value = "free" },
        new() { Label = "Basic - £9/month", Value = "basic" },
        new() { Label = "Pro - £29/month", Value = "pro" },
        new() { Label = "Enterprise - Contact us", Value = "enterprise" }
    };
}

Keyboard navigation

Radio buttons are native radio inputs. A group is a single Tab stop.
Key What it does
Tab Moves focus into the group, onto the selected option, or the first option when none is selected.
Arrow Down or Arrow Right Moves to the next option and selects it.
Arrow Up or Arrow Left Moves to the previous option and selects it.
Space Selects the focused option when none is selected yet.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwRadioButtonTheme), 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.
Property Type Controls
Base string
Disabled string
Hover string
LabelBase string
LabelInteractiveCursor string
LabelNonInteractiveCursor string
LabelDisabled string
IconWrapper 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: TwRadioButtonTheme on the API docs.

On this page

  • Basic usage
  • Colors
  • Data-driven (automatic)
  • Horizontal layout & custom spacing
  • Disabled state
  • Programmatic control
  • 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