Forms
TwRadioButton
TwRadioButton is a Blazor radio button component. Bind SelectedValue, set Color, Disabled and Horizontal, or generate a group from Items.
Last updated
Basic Usage
Group radio buttons with
TwRadioGroup and bind values with @bind-SelectedValue.Selected: standard
Colors
TwRadioButton supports all the standard theme colors via the
Color property.Data-Driven (Automatic)
Use
Items and @bind-Value to generate radio buttons from a list.Selected: medium
Rating: 3 / 5
Horizontal Layout & Custom Spacing
Use
Horizontal to arrange buttons side-by-side, or Class="gap-4" for custom spacing.Selected: credit
Selected: monthly
Disabled State
Disable the entire group with the
Disabled property.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.
Current plan: free
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.