ShellUI Logo
ShellUI

Radio Group

Radio button group for single selection from multiple choices.

The RadioGroup and RadioGroupItem components provide a group of radio buttons for selecting a single option.

Installation

shellui add radio-group

Usage

Basic

<RadioGroup Value="@selected" ValueChanged="@HandleChanged">
  <RadioGroupItem Value="option1">Option 1</RadioGroupItem>
  <RadioGroupItem Value="option2">Option 2</RadioGroupItem>
  <RadioGroupItem Value="option3">Option 3</RadioGroupItem>
</RadioGroup>

@code {
    private string? selected;

    private void HandleChanged(string value)
    {
        selected = value;
    }
}

Two-way Binding

<RadioGroup @bind-Value="selectedSize">
  <RadioGroupItem Value="sm">Small</RadioGroupItem>
  <RadioGroupItem Value="md">Medium</RadioGroupItem>
  <RadioGroupItem Value="lg">Large</RadioGroupItem>
</RadioGroup>

@code {
    private string? selectedSize;
}

With Label

<div class="space-y-4">
  <Label>Select Size</Label>
  <RadioGroup @bind-Value="selectedSize">
    <RadioGroupItem Value="xs">Extra Small</RadioGroupItem>
    <RadioGroupItem Value="sm">Small</RadioGroupItem>
    <RadioGroupItem Value="md">Medium</RadioGroupItem>
    <RadioGroupItem Value="lg">Large</RadioGroupItem>
  </RadioGroup>
</div>

@code {
    private string? selectedSize;
}

Disabled Item

<RadioGroup @bind-Value="selected">
  <RadioGroupItem Value="active">Active</RadioGroupItem>
  <RadioGroupItem Value="disabled" Disabled="true">Disabled</RadioGroupItem>
  <RadioGroupItem Value="other">Other</RadioGroupItem>
</RadioGroup>

@code {
    private string? selected;
}

API Reference

RadioGroup

ParameterTypeDefaultDescription
Valuestring?nullCurrently selected value
ValueChangedEventCallback<string>Fires when selection changes
ChildContentRenderFragmentnullRadioGroupItem children

RadioGroupItem

ParameterTypeDefaultDescription
ValuestringItem value (required)
ChildContentRenderFragmentnullItem label content
DisabledboolfalseDisables this radio item

Accessibility

  • Proper ARIA attributes (role="radio", aria-checked)
  • Arrow key navigation between items
  • Screen reader compatible

On this page