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
TThe type of value in the radio group.
- Inheritance
-
TwRadioGroup<T>
- Implements
- Inherited Members
Remarks
TwRadioGroup provides two ways to use radio groups:
- Manual: Add TwRadioButton components as children (ChildContent)
- 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
Disabled
Gets or sets whether the entire radio group is disabled.
[Parameter]
public bool Disabled { get; set; }
Property Value
Horizontal
Gets or sets the orientation of the radio group.
[Parameter]
public bool Horizontal { get; set; }
Property Value
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
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
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
LegendClass
Gets or sets the CSS class for the legend element.
[Parameter]
public string? LegendClass { get; set; }
Property Value
Name
Gets or sets the name for all radio buttons in the group.
[Parameter]
public string? Name { get; set; }
Property Value
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
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder