Infragistics
Close
Angular React Web Components Blazor Angular
Open Source

Radio Group

The Angular 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 Angular 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 Angular Radio Group. Each radio button pairs its radio control with label content, which can be placed before or after the control.

igx-radio-group                  — groups the radio buttons
└── igx-radio                    — one per option
    ├── input.igx-radio__input   — the native radio input
    ├── .igx-radio__composite    — the radio control
    └── .igx-radio__label        — the projected label content

Getting Started

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

Import the Radio component and the IgxRadioGroupDirective directive:

import { IgxRadioComponent, IgxRadioGroupDirective } from 'igniteui-angular/radio';

Add both to the imports collection of your component, or add the IGX_RADIO_GROUP_DIRECTIVES collection, which contains them, and then use the igx-radio-group and igx-radio elements in your template.

After registration, place the Angular 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.

<igx-radio-group name="fruit" alignment="vertical" value="apple">
  <igx-radio value="apple">Apple</igx-radio>
  <igx-radio value="banana">Banana</igx-radio>
  <igx-radio value="mango">Mango</igx-radio>
</igx-radio-group>

Prerequisites and Version Compatibility

The Angular 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-angular 22.2.0

Usage

Layout

The Angular 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.

<igx-radio-group name="color" alignment="vertical" value="yellow">
  <igx-radio value="yellow" labelPosition="before">Yellow</igx-radio>
  <igx-radio value="orange" labelPosition="before">Orange</igx-radio>
</igx-radio-group>

A radio button can also be labelled by an element outside of it. Reference the element with aria-labelledby when you need full control over where the label sits and how it looks.

<span id="radio-label">Express delivery</span>
<igx-radio aria-labelledby="radio-label" value="express"></igx-radio>

Orientation

The Angular 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 horizontal.

<igx-radio-group name="chart" alignment="horizontal" value="line">
  <igx-radio value="line">Line</igx-radio>
  <igx-radio value="bar">Bar</igx-radio>
  <igx-radio value="pie">Pie</igx-radio>
</igx-radio-group>

Interaction States

The Angular 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.

<igx-radio value="daily" [invalid]="true">Daily Updates</igx-radio>

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 Angular Radio. A disabled radio button can’t be selected, and keyboard navigation skips it.

<igx-radio-group name="age" alignment="vertical" value="18-27">
  <igx-radio value="18-27">18-27</igx-radio>
  <igx-radio value="28-39">28-39</igx-radio>
  <igx-radio value="40-55" [disabled]="true">40-55</igx-radio>
</igx-radio-group>

On/Off States

A Angular 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.

<igx-radio-group name="age" alignment="vertical" value="18-27">
  <igx-radio value="18-27">18-27</igx-radio>
  <igx-radio value="28-39">28-39</igx-radio>
  <igx-radio value="40-55">40-55</igx-radio>
</igx-radio-group>

Forms

The Angular 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.

The Radio Group works with template-driven and reactive forms. Bind the selected value with ngModel or a form control on igx-radio-group:

<form [formGroup]="fruitsForm">
  <igx-radio-group name="fruit" alignment="vertical" formControlName="favoriteFruit">
    <igx-radio value="apple">Apple</igx-radio>
    <igx-radio value="banana">Banana</igx-radio>
    <igx-radio value="orange">Orange</igx-radio>
  </igx-radio-group>
</form>

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 Angular Radio and Radio Group options documented on this page. See the API references for the complete generated list.

Name Type Default Description
checked boolean false Gets or sets whether the radio button is on.
disabled boolean false Gets or sets whether the radio button is disabled.
invalid boolean false Gets or sets whether the radio button is in the invalid state.
labelPosition LabelPosition after Sets whether the label is placed before or after the radio control.
required boolean false Gets or sets whether a selection is required.
value any — Gets or sets the value submitted with the form when the radio button is on.
alignment (Radio Group) RadioGroupAlignment horizontal Sets whether the radio buttons are stacked in a column or placed in a row.
value (Radio Group) any — Gets or sets the value of the radio button that is on.
name string — Gets or sets the name that groups radio buttons together.
name (Radio Group) string — Gets or sets the name applied to all radio buttons in the group.

Methods

The Angular Radio exposes the following methods.

Name Description
select() Turns the radio button on and emits the change event. It does nothing when the radio button is already on.
deselect() Turns the radio button off without emitting the change event.

Events

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

Name Description
change (Radio and Radio Group) Emitted when the checked state of a radio button changes. The event arguments carry the checked state and the value of the radio button.

Styling

The Angular Radio is styled through the Ignite UI for Angular theme and the CSS variables it generates. 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-angular/theming" as *;

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

:host {
  @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.

Styling with Tailwind

You can style the Angular 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:

<igx-radio class="!light-radio ![--empty-color:#576E60] ![--fill-color:#7B9E89]" value="tokyo">Tokyo</igx-radio>

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

Accessibility

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

Keyboard Interaction

The Angular 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.

Screen Readers / ARIA

  • Each Angular Radio renders a native <input type="radio">, which exposes the radio role, the checked state, and the disabled and required states. The input also sets aria-invalid from the invalid property.

  • The label content of the radio button is its accessible name. When the label is outside the component, connect it with aria-labelledby.

  • The igx-radio-group element doesn’t render a radiogroup role. Add role="radiogroup" and an accessible name, for example with aria-labelledby, when the group needs to be announced as one question.

Accessibility Compliance

Verify the rendered Angular 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. Show it in the surrounding form.
  • Test the rendered Radio Group with keyboard navigation and the assistive technologies your users rely on.

Known Limitations

The Angular Radio and Radio Group have the following known limitation:

  • The igx-radio-group element doesn’t render a radiogroup role. Add the role and an accessible name to the element yourself.

API References

Dependencies

The Angular Radio requires a theme stylesheet to apply its visual styling. See the framework-specific setup in Getting Started. The Radio also uses the IgxRipple Theme for its ripple effect.

Additional Resources

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

The Angular 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 Angular 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 Angular 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 ngModel or a form control on igx-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 Angular Radio Group value to the value of the radio button you want to turn on. Setting the Radio Group value doesn’t fire the change event. To select a radio button and fire the change event, call the select() method of that radio button.

How do I clear the selection of a Radio Group?

Users can’t turn off a selected Angular Radio by clicking it again, which is the standard radio button behavior. To clear the selection in code, set the Radio Group value, or the form control bound to the group, to null. 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?

Angular Radio buttons are mutually exclusive when they’re placed in the same igx-radio-group, which generates a shared name when you don’t set one. Place radio buttons that belong together in one Radio Group instead of using standalone radio buttons.

How do I make a selection required in a form?

Set required on the Angular Radio Group, or add Validators.required to the form control bound to the group. The form stays invalid until the user turns on one of the radio buttons.

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

When the Angular Radio Group is bound to a reactive form control, call disable() on the control to disable all of its radio buttons. Without a form control, set disabled on each igx-radio, because the Radio Group doesn’t have a disabled input.