ChoiceGroup
Description
The ChoiceGroup component allows users to select a single option from a set of mutually exclusive choices, similar to a group of radio buttons. It is ideal for presenting between 2 to 7 options clearly when the selection is important enough to justify using multiple visible controls. Each option in the group is defined by a nested Choice component, and the ChoiceGroup supports both vertical and horizontal layouts. Use this component when you need to emphasize all available options equally.
Usage
Instantiate a ChoiceGroup using the static helper method from Tesserae.UI. You can add choices using the fluent API via the Choices method and configure the component with methods such as Horizontal() and Required().
API reference
public sealed class ChoiceGroup : ComponentBase<ChoiceGroup, HTMLDivElement>, IContainer<ChoiceGroup, ChoiceGroup.Choice>, IObservableComponent<ChoiceGroup.Choice>A group of radio-style choices of which exactly one may be selected at a time.
Constructors
Properties
public Choice SelectedOption { get ; private set ; }Gets or sets the selected option.
public string Label { get ; set ; }Gets or sets the label shown by the component.
public ChoiceGroupOrientation Orientation { get ; set ; }Gets or sets the orientation.
Methods
public override HTMLElement Render()Renders the component's root HTML element.
public void Replace(Choice newComponent, Choice oldComponent)Replaces an existing item with a new one.
public ChoiceGroup Choices(params ChoiceGroup.Choice[] children)Configures the component to choices.
Samples
Default ChoiceGroup
This sample demonstrates a basic ChoiceGroup with four options. One of the options is disabled to prevent selection.
Horizontal and Required ChoiceGroup
This sample shows how to create a horizontal ChoiceGroup with a custom label and marked as required.