Table of Contents

Class TwRadioGroup<T>

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Represents a container component for grouping multiple TwRadioButton<T> components together.

public class TwRadioGroup<T> : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent

Type Parameters

T

The type of value in the radio group.

Inheritance
TwRadioGroup<T>
Implements
Inherited Members

Remarks

TwRadioGroup provides two ways to use radio groups:

  1. Manual: Add TwRadioButton components as children (ChildContent)
  2. Automatic: Provide Items and bind to Value for automatic radio button generation Radio buttons within the group should share the same Name parameter to form a mutually exclusive group. The group can be oriented horizontally or vertically, and supports customizable spacing. The component supports cascading the Name to child radio buttons.

Constructors

TwRadioGroup()

public TwRadioGroup()

Properties

ChildContent

Gets or sets the content to display within the radio group.

[Parameter]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

Disabled

Gets or sets whether the entire radio group is disabled.

[Parameter]
public bool Disabled { get; set; }

Property Value

bool

Horizontal

Gets or sets the orientation of the radio group.

[Parameter]
public bool Horizontal { get; set; }

Property Value

bool

Remarks

Default is vertical. Set to true for horizontal orientation.

ItemColor

Gets or sets the color for automatically generated radio buttons.

[Parameter]
public Color? ItemColor { get; set; }

Property Value

Color?

Items

Gets or sets the collection of items to display as radio buttons (for automatic mode).

[Parameter]
public IEnumerable<RadioGroupItem<T>>? Items { get; set; }

Property Value

IEnumerable<RadioGroupItem<T>>

Remarks

When provided, radio buttons are automatically generated from the items. If not provided, use ChildContent to manually add radio buttons.

Legend

Gets or sets the legend text for the radio group.

[Parameter]
public string? Legend { get; set; }

Property Value

string

LegendClass

Gets or sets the CSS class for the legend element.

[Parameter]
public string? LegendClass { get; set; }

Property Value

string

Name

Gets or sets the name for all radio buttons in the group.

[Parameter]
public string? Name { get; set; }

Property Value

string

Remarks

This value is cascaded to child radio buttons to form a mutually exclusive group.

Value

Gets or sets the selected value.

[Parameter]
public T? Value { get; set; }

Property Value

T

ValueChanged

Gets or sets the callback invoked when the selected value changes.

[Parameter]
public EventCallback<T> ValueChanged { get; set; }

Property Value

EventCallback<T>

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder