Skip to content
GitHub11 stars

A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.

<RadioGroup Value="comfortable" Class="w-fit">
    <div class="flex items-center gap-3">
        <RadioGroupItem Value="default" id="r1" />

Installation

dnx Blazix.Cli add radio-group

Usage

<RadioGroup Value="option-one">
    <div class="flex items-center gap-3">
        <RadioGroupItem Value="option-one" id="option-one" />
        <Label for="option-one">Option One</Label>
    </div>
    <div class="flex items-center gap-3">
        <RadioGroupItem Value="option-two" id="option-two" />
        <Label for="option-two">Option Two</Label>
    </div>
</RadioGroup>

Composition

Use the following composition to build a RadioGroup:

RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Description

Radio group items with a description using the Field component.

Standard spacing for most use cases.

More space between elements.

Minimal spacing for dense layouts.

<RadioGroup Value="comfortable" Class="w-fit">
    <Field Orientation="FieldOrientation.Horizontal">
        <RadioGroupItem Value="default" id="desc-r1" />

Choice Card

Use FieldLabel to wrap the entire Field for a clickable card-style selection.

<RadioGroup Value="plus" Class="max-w-sm">
    <FieldLabel for="plus-plan">
        <Field Orientation="FieldOrientation.Horizontal">

Fieldset

Use FieldSet and FieldLegend to group radio items with a label and description.

Subscription Plan

Yearly and lifetime plans offer significant savings.

<FieldSet Class="w-full max-w-xs">
    <FieldLegend Variant="FieldLegendVariant.Label">Subscription Plan</FieldLegend>
    <FieldDescription>Yearly and lifetime plans offer significant savings.</FieldDescription>

Disabled

Use the Disabled parameter on RadioGroup to disable all items.

<RadioGroup Value="option2" Class="w-fit">
    <Field Orientation="FieldOrientation.Horizontal" data-disabled>
        <RadioGroupItem Value="option1" id="disabled-1" Disabled="true" />

Invalid

Use aria-invalid on RadioGroupItem and data-invalid on Field to show validation errors.

Notification Preferences

Choose how you want to receive notifications.

<FieldSet Class="w-full max-w-xs">
    <FieldLegend Variant="FieldLegendVariant.Label">Notification Preferences</FieldLegend>
    <FieldDescription>Choose how you want to receive notifications.</FieldDescription>

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

تباعد قياسي لمعظم حالات الاستخدام.

مساحة أكبر بين العناصر.

تباعد أدنى للتخطيطات الكثيفة.

<RadioGroup Value="comfortable" Class="w-fit">
    @foreach (var (value, label, description) in T.Options)
    {

API Reference

RadioGroup

ParameterTypeDefault
Render RenderFragment<RadioGroupRenderProps>? -
Value string? -
ValueChanged EventCallback<string?> -
OnValueChange EventCallback<ValueChangeEventArgs<string?>> -
Disabled bool false
ReadOnly bool false
Required bool false
Name string? -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

RadioGroupItem

ParameterTypeDefault
Render RenderFragment<RadioRenderProps>? -
Valuerequired string -
Disabled bool false
ReadOnly bool false
Required bool false
InputId string? -
Class string? -

Other attributes are passed to the element it renders.