Infragistics
Close
Angular React Web Components Blazor Blazor
Open Source

Radio Group

The Blazor Radio and Radio Group are components that let users select exactly one option from a set of mutually exclusive options. Each radio button represents one option, and the Radio Group arranges the radio buttons in a vertical or horizontal layout.

Live Demo

Anatomy

The Blazor Radio Group contains radio buttons, and each radio button is made of a radio control and a label.

Radio Group anatomy showing the label, the radio control, and the group of radio buttons
1. Radio Button Label: indicates the content you want to select or unselect
2. Radio Button: indicates if the state is selected. The default state of the input is unselected
3. Button Group: a container that groups related options and allows only one selection at a time

The following diagram shows the element structure of the Blazor Radio Group. Each radio button pairs its radio control with label content, which can be placed before or after the control.

igc-radio-group                  — groups the radio buttons
└── igc-radio                    — one per option
    └── [part="base"]            — the <label> that wraps the input, the control, and the label
        ├── input[type="radio"]  — the native radio input
        ├── [part="control"]     — the radio control
        └── [part="label"]       — the slotted label content

Getting Started

To use the Blazor Radio and Radio Group, follow the Ignite UI for Blazor Getting Started topic for the basic project setup, then import or register the components for your target platform.

Register the Ignite UI for Blazor services:

// in Program.cs file

builder.Services.AddIgniteUIBlazor();

Registering IgbRadioGroupModule, the client resource module of the IgbRadioGroup, is optional: the component loads its resources when it first renders. Listing it in builder.Services.AddIgniteUIBlazor(typeof(IgbRadioGroupModule)) can be used to preload resources or to support elements created only on the client; it also registers the radio elements inside the group. A IgbRadio used on its own has its own module, IgbRadioModule (see Component Modules).

Then add the theme stylesheet to your host page:

<link href="_content/IgniteUI.Blazor/themes/light/bootstrap.css" rel="stylesheet" />

After registration, place the Blazor Radio components inside a Radio Group and give the group a name, so that users can select only one of the options. Set value on each radio button to identify the selected option.

<IgbRadioGroup name="fruit">
    <IgbRadio Value="apple" Checked="true">Apple</IgbRadio>
    <IgbRadio Value="banana">Banana</IgbRadio>
    <IgbRadio Value="mango">Mango</IgbRadio>
</IgbRadioGroup>

The Blazor Radio components are mutually exclusive only when they share a name. The Radio Group applies its name to every radio button it contains; radio buttons without a name act independently of each other.

Prerequisites and Version Compatibility

The Blazor Radio and Radio Group ship in the following package. The samples in this topic are built with the version listed next to it.

Package Version used in the samples
IgniteUI.Blazor (or IgniteUI.Blazor.Trial) 26.1.98

Usage

Layout

The Blazor Radio places its label after the radio control by default. Set the labelPosition property to before to place the label before the control. In a vertical Radio Group, radio buttons with the label before the control align to the end of the group.

Place the radio buttons as direct children of the Radio Group. Radio buttons inside a wrapper element aren’t part of the group, and the group doesn’t lay them out.

<IgbRadioGroup name="color">
    <IgbRadio Value="yellow" LabelPosition="ToggleLabelPosition.Before" Checked="true">Yellow</IgbRadio>
    <IgbRadio Value="orange" LabelPosition="ToggleLabelPosition.Before">Orange</IgbRadio>
</IgbRadioGroup>

Orientation

The Blazor Radio Group stacks its radio buttons in a column or places them in a row. Set the alignment property to vertical or horizontal. The default alignment is vertical.

<IgbRadioGroup name="chart" Alignment="ContentOrientation.Horizontal">
    <IgbRadio Value="line" Checked="true">Line</IgbRadio>
    <IgbRadio Value="bar">Bar</IgbRadio>
    <IgbRadio Value="pie">Pie</IgbRadio>
</IgbRadioGroup>

Interaction States

The Blazor Radio shows a hover state when the pointer is over it and a focus ring when it receives keyboard focus. Set the invalid property to show the invalid state, which draws the radio control in the error color of the theme.

<IgbRadio Value="daily" Invalid="true">Daily Updates</IgbRadio>

The following sample shows the hover, focused, and focused and hovered states for checked, unchecked, and invalid radio buttons.

Disabled States

Set the disabled property to disable a Blazor Radio. A disabled radio button can’t be selected, and keyboard navigation skips it.

<IgbRadioGroup name="age">
    <IgbRadio Value="18-27" Checked="true">18-27</IgbRadio>
    <IgbRadio Value="28-39">28-39</IgbRadio>
    <IgbRadio Value="40-55" Disabled="true">40-55</IgbRadio>
</IgbRadioGroup>

On/Off States

A Blazor Radio is either on (checked) or off. Set the checked property on a radio button to turn it on, or set the value of the Radio Group to turn on the radio button with the matching value. Turning a radio button on turns off the other radio buttons in the group.

<IgbRadioGroup name="age" Value="18-27">
    <IgbRadio Value="18-27">18-27</IgbRadio>
    <IgbRadio Value="28-39">28-39</IgbRadio>
    <IgbRadio Value="40-55">40-55</IgbRadio>
</IgbRadioGroup>

Forms

The Blazor Radio submits the value of the selected radio button under the group’s name. Set the required property on a radio button of the group to require a selection before the form is submitted.

To show a message when the selection is missing, put it in the value-missing slot of a radio button. The required selection makes every radio button of the group invalid, so place the message in the last radio button to show it below the group.

<IgbRadioGroup name="fruit">
    <IgbRadio Value="apple" Required="true">Apple</IgbRadio>
    <IgbRadio Value="banana">Banana</IgbRadio>
    <IgbRadio Value="orange">
        Orange
        <span slot="value-missing">Choose a fruit.</span>
    </IgbRadio>
</IgbRadioGroup>

The IgbRadio component doesn’t work with a standard HTML <form> element in Blazor. Use the Blazor EditForm component instead.

Do/Don’t

When extending a Radio Group with additional items, make sure that they are aligned consistently and form a single column. Avoid layout in multiple columns, as well as situations with more than one Radio element with on state at a time.

Do: list the radio buttons of a group in a single column with one option on. Don't: split them into multiple columns or turn on more than one option.

Properties

The following properties cover the Blazor Radio and Radio Group options documented on this page. See the API references for the complete generated list.

Name Type Default Description
Checked bool false Gets or sets whether the radio button is on.
Disabled bool false Gets or sets whether the radio button is disabled.
Invalid bool false Gets or sets whether the radio button is in the invalid state.
LabelPosition ToggleLabelPosition ToggleLabelPosition.After Sets whether the label is placed before or after the radio control.
Required bool false Gets or sets whether a selection is required.
Value string — Gets or sets the value submitted with the form when the radio button is on.
Alignment (Radio Group) ContentOrientation ContentOrientation.Vertical Sets whether the radio buttons are stacked in a column or placed in a row.
Value (Radio Group) string — Gets or sets the value of the radio button that is on.

Methods

The Blazor Radio exposes the following methods.

Name Description
CheckValidity() Checks the validity of the radio button and returns true when it’s valid.
ReportValidity() Checks the validity of the radio button, shows its invalid state when it isn’t valid, and returns true when it’s valid.
SetCustomValidity(message) Sets a custom validation message. Pass an empty string to clear it.
Click() Simulates a click on the radio button, which turns it on.
FocusComponent(options) Moves focus to the radio button.
BlurComponent() Removes focus from the radio button.

Each method also has an asynchronous version that returns a Task, for example CheckValidityAsync().

Events

The Blazor Radio emits an event when the user turns a radio button on.

Name Description
Change Emitted when the checked state of a radio button changes. The event arguments carry the checked state and the value of the radio button.
ValueChanged (Radio Group) Raised with the new value of the Radio Group when its selection changes. @bind-Value uses it.
CheckedChanged Raised with the new checked state of the radio button. @bind-Checked uses it.

Styling

The Blazor Radio is styled through the Ignite UI for Blazor theme and the CSS variables it generates. CSS parts give you access to the internal elements of the radio button. The following sample draws the radio buttons of a shipping form with a custom palette and typeface.

Sass Theming

Create a theme with the radio-theme function and include it with the tokens mixin. Setting $empty-color and $fill-color is enough for a fully styled radio button, because the theme derives the remaining colors from them.

@use "igniteui-theming" as *;

$custom-radio-theme: radio-theme(
  $empty-color: #345779,
  $fill-color: #2dabe8,
);

:root {
  @include tokens($custom-radio-theme);
}

When you set a primary parameter, the theme derives its dependent parameters:

Primary parameter Dependent parameters What it changes
$empty-color $hover-color, $focus-outline-color (Indigo) The border of an unchecked radio button.
$fill-color $fill-color-hover, $fill-hover-border-color, $focus-border-color (Bootstrap), $focus-outline-color (Bootstrap), $focus-outline-color-filled (Indigo) The border and dot of a checked radio button.
$label-color $label-color-hover The label text.
$error-color $error-color-hover, $focus-outline-color-error The label, border, and dot in the invalid state.

CSS Variables

Set the following CSS variables on a radio button, or on one of its ancestors, to change its colors without a Sass theme:

Variable What it changes
--ig-radio-label-color The label text.
--ig-radio-empty-color The border of an unchecked radio button.
--ig-radio-empty-fill-color The fill of an unchecked radio button.
--ig-radio-fill-color The border and dot of a checked radio button.
--ig-radio-hover-color The border and dot on hover.
--ig-radio-fill-color-hover The dot of a checked radio button on hover.
--ig-radio-error-color The label, border, and dot in the invalid state.
--ig-radio-disabled-color The border and dot of a disabled radio button.
--ig-radio-disabled-label-color The label of a disabled radio button.
--ig-radio-focus-outline-color The focus outline.

Style Parts

Use the following CSS parts to target the internal elements of the Blazor Radio. Each part also carries the checked part name while the radio button is on, so ::part(control checked) targets only a checked radio control.

Part What it styles
base The wrapper of the radio control and the label.
control The radio control.
label The label.
igc-radio {
  --ig-radio-fill-color: #0176ff;
  --ig-radio-empty-color: #a9b8cc;
}

igc-radio::part(label) {
  color: #002b5c;
  font-weight: 600;
}

Styling with Tailwind

You can style the Blazor Radio with the custom Tailwind utility classes from igniteui-theming. Make sure to set up Tailwind first, then import the utilities in your global stylesheet:

@import "tailwindcss";
@import "igniteui-theming/tailwind/utilities/material.css";

Use the light-radio or dark-radio class for the corresponding theme and override its CSS variables with arbitrary properties:

<IgbRadio Class="!light-radio ![--empty-color:#576E60] ![--fill-color:#7B9E89]" Value="tokyo">Tokyo</IgbRadio>

The exclamation mark (!) gives the Tailwind utility precedence over the default theme styles of the Radio.

Accessibility

The Blazor Radio renders a native radio input, so assistive technologies announce each radio button with its role, label, and checked state.

Keyboard Interaction

The Blazor Radio Group moves focus and selection between its enabled radio buttons with the arrow keys. Disabled radio buttons are skipped.

Key Action
Tab / Shift+Tab Moves focus into or out of the Radio Group.
Arrow Down / Arrow Right Moves focus to the next enabled radio button and turns it on. From the last radio button, moves to the first one. In right-to-left layouts, Arrow Right moves to the previous radio button.
Arrow Up / Arrow Left Moves focus to the previous enabled radio button and turns it on. From the first radio button, moves to the last one. In right-to-left layouts, Arrow Left moves to the next radio button.
Space Turns on the focused radio button.
Enter Submits the form that contains the radio button.

When a radio button in the group is on, it is the only tab stop of the group. When none of the radio buttons is on, each of them is a tab stop.

In IgniteUI.Blazor 26.1, clearing the selection in code leaves no tab stop in the group. See Known Limitations.

Screen Readers / ARIA

  • Each Blazor Radio renders a native <input type="radio">, which exposes the radio role, the checked state, and the disabled and required states.

  • The label content of the radio button is its accessible name.

  • The Radio Group renders the radiogroup role. In IgniteUI.Blazor 26.1, it doesn’t set aria-orientation.

  • Give the Radio Group an accessible name, for example with aria-labelledby pointing to the question it answers.

Accessibility Compliance

Verify the rendered Blazor Radio and Radio Group against the accessibility requirements of your application.

Criterion How the component supports the requirement
2.1.1 Keyboard Users move between the enabled radio buttons and turn them on with the arrow keys and Space.
4.1.2 Name, Role, Value Each radio button exposes its label as the accessible name, the radio role, and its checked state through the native radio input.

Your responsibilities:

  • Give every radio button meaningful label content, and give the Radio Group an accessible name.
  • Keep the focus ring visible and preserve sufficient contrast when you customize the Radio colors.
  • Show a validation message when the Radio is invalid, so the error isn’t conveyed by color alone. Use the value-missing slot, as shown in Forms.
  • Test the rendered Radio Group with keyboard navigation and the assistive technologies your users rely on.

Known Limitations

The Blazor Radio and Radio Group have the following known limitations:

  • The Radio doesn’t work with a standard HTML <form> element in Blazor. Use the Blazor EditForm component instead.
  • In IgniteUI.Blazor 26.1, a radio button can’t be labelled by an element outside of it. IgbRadio has no AriaLabelledBy parameter, and an aria-labelledby attribute doesn’t give the radio button an accessible name. Put the label text inside the radio button.
  • In IgniteUI.Blazor 26.1, clearing the selection in code takes every radio button out of the tab order. Keyboard users can’t reach the group until a mouse click or your code turns one of its radio buttons on again.

API References

Dependencies

The Blazor Radio requires a theme stylesheet to apply its visual styling. See the framework-specific setup in Getting Started.

Additional Resources

Use the following Blazor resources for API details and project support:

The Blazor Radio is intended for one choice from a short list of mutually exclusive options. Use the following related components for other kinds of choices:

  • Checkbox - Use Checkbox when users can select more than one option.
  • Switch - Use Switch when the control turns a single setting on or off immediately.
  • Select - Use Select when the list of options is long or space is limited.

FAQ

These frequently asked questions cover common Blazor Radio and Radio Group selection, form, and state scenarios.

How do I get the selected value when the user changes the selection?

Handle the Change event on the Blazor Radio Group. The change event arguments carry the value of the radio button the user turned on. You can also bind the selected value with @bind-Value on the Radio Group. The change event doesn’t fire when you set the Radio Group value in code.

How do I select a radio button from code?

Set the Blazor Radio Group value to the value of the radio button you want to turn on. You can also set checked on that radio button, which turns off the other radio buttons in the group. Selecting a radio button in code doesn’t fire the change event.

How do I clear the selection of a Radio Group?

Users can’t turn off a selected Blazor Radio by clicking it again, which is the standard radio button behavior. To clear the selection in code, set the Radio Group value to an empty string or another value that none of its radio buttons has. In IgniteUI.Blazor 26.1, this also takes every radio button out of the tab order, as described in Known Limitations. If users need to clear the selection themselves, add a “None” option or a separate clear button.

Why can more than one radio button be on at the same time?

Blazor Radio buttons are mutually exclusive only when they share the same name, so radio buttons without a shared name can be on at the same time. Set name on the Radio Group, which applies it to all of its radio buttons, or set the same name on each radio button.

How do I make a selection required in a form?

Set required on any radio button of the Blazor Radio Group, and the whole group requires a selection. Place the Radio Group in a Blazor EditForm, because the Radio doesn’t work with a standard HTML <form> element in Blazor.

How do I disable all radio buttons of a Radio Group?

The Blazor Radio Group doesn’t have a disabled property of its own. To disable the whole group, set disabled on each of its radio buttons, for example by binding all of them to the same state.