Accent color
# ChoiceGroup **Also known as:** Radio, RadioButton, RadioGroup, RadioButtonGroup ## Description ChoiceGroup lets people select a single option from two or more choices. ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | AriaLabelledBy | `string?` | null | Id of an element to use as the aria label for the ChoiceGroup. | | ChildContent | `RenderFragment?` | null | The content of the ChoiceGroup, a list of BitChoiceGroupOption components. | | Classes | `BitChoiceGroupClassStyles?` | null | Custom CSS classes for different parts of the BitChoiceGroup. | | Color | `BitColor?` | null | The general color of the ChoiceGroup. | | Inline | `bool` | false | Renders the icons and images in a single line with the items in the ChoiceGroup. | | Horizontal | `bool` | false | Renders the items in the ChoiceGroup horizontally. | | Items | `IEnumerable<TItem>` | new List<TItem>() | Sets the data source that populates the items of the list. | | ItemLabelTemplate | `RenderFragment<TItem>?` | | Used to customize the label for the Item Label content. | | ItemPrefixTemplate | `RenderFragment<TItem>?` | | Used to add a prefix to each item. | | ItemTemplate | `RenderFragment<TItem>?` | null | Used to customize the label for the Item content. | | Label | `string?` | null | The label for the ChoiceGroup. | | LabelTemplate | `RenderFragment?` | null | Custom RenderFragment for the label of the ChoiceGroup. | | Name | `string` | Guid.NewGuid().ToString() | Name of the ChoiceGroup, this unique name is used to group each item into the same logical component. | | NameSelectors | `BitChoiceGroupNameSelectors<TItem, TValue>?` | null | Names and selectors of the custom input type properties. | | NoCircle | `bool` | false | Removes the circle from the start of each item. | | OnClick | `EventCallback<MouseEventArgs>` | | Callback for when the option clicked. | | Options | `RenderFragment?` | null | Alias of ChildContent. | | Reversed | `bool` | false | Reverses the label and radio button location. | | Size | `BitSize?` | null | The size of the BitChoiceGroup. | | Styles | `BitChoiceGroupClassStyles?` | null | Custom CSS styles for different parts of the BitChoiceGroup. | | DefaultValue | `TValue?` | null | The default value of the input to be used in uncontrolled mode (i.e. when the Value is not bound), typically used alongside the OnChange callback. | | DisplayName | `string?` | null | Gets or sets the display name for this field. | | InputHtmlAttributes | `IReadOnlyDictionary<string, object>?` | null | Gets or sets a collection of additional attributes that will be applied to the created element. | | Name | `string?` | null | Gets or sets the name of the element. Allows access by name from the associated form. | | NoValidate | `bool` | false | Disables the validation of the input. | | OnChange | `EventCallback<TValue?>` | | Callback for when the input value changes. | | ReadOnly | `bool` | false | Makes the input read-only. | | Required | `bool` | false | Makes the input required. | | Value | `TValue?` | null | Gets or sets the value of the input. This should be used with two-way binding. | | AriaLabel | `string?` | null | Gets or sets the accessible label for the component, used by assistive technologies. | | Class | `string?` | null | Gets or sets the CSS class name(s) to apply to the rendered element. | | Dir | `BitDir?` | null | Gets or sets the text directionality for the component's content. | | ForceAnimation | `bool` | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. | | HtmlAttributes | `Dictionary<string, object>` | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. | | Id | `string?` | null | Gets or sets the unique identifier for the component's root element. | | IsEnabled | `bool` | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. | | Style | `string?` | null | Gets or sets the CSS style string to apply to the rendered element. | | TabIndex | `string?` | null | Gets or sets the tab order index for the component when navigating with the keyboard. | | Visibility | `BitVisibility` | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. | ## Public Members | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | InputElement | `ElementReference` | | The ElementReference of the input element. | | FocusAsync() | `() => ValueTask` | | Gives focus to the input element. | | FocusAsync(bool preventScroll) | `(bool preventScroll) => ValueTask` | | Gives focus to the input element. | | UniqueId | `Guid` | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. | | RootElement | `ElementReference` | | Gets the reference to the root HTML element associated with this component. | ## Enums ### BitColor Enum | Name | Value | Description | | :--- | :--- | :---------- | | Primary | 0 | Info Primary general color. | | Secondary | 1 | Secondary general color. | | Tertiary | 2 | Tertiary general color. | | Info | 3 | Info general color. | | Success | 4 | Success general color. | | Warning | 5 | Warning general color. | | SevereWarning | 6 | SevereWarning general color. | | Error | 7 | Error general color. | | PrimaryBackground | 8 | Primary background color. | | SecondaryBackground | 9 | Secondary background color. | | TertiaryBackground | 10 | Tertiary background color. | | PrimaryForeground | 11 | Primary foreground color. | | SecondaryForeground | 12 | Secondary foreground color. | | TertiaryForeground | 13 | Tertiary foreground color. | | PrimaryBorder | 14 | Primary border color. | | SecondaryBorder | 15 | Secondary border color. | | TertiaryBorder | 16 | Tertiary border color. | ### BitSize Enum | Name | Value | Description | | :--- | :--- | :---------- | | Small | 0 | The small size checkbox. | | Medium | 1 | The medium size checkbox. | | Large | 2 | The large size checkbox. | ### BitVisibility Enum | Name | Value | Description | | :--- | :--- | :---------- | | Visible | 0 | The content of the component is visible. | | Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). | | Collapsed | 2 | The component is hidden (display:none). | ### BitDir Enum | Name | Value | Description | | :--- | :--- | :---------- | | Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). | | Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). | | Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. | ## Sub Classes ### BitChoiceGroupItem Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | AriaLabel | `string?` | null | AriaLabel attribute for the BitChoiceGroup item. | | Class | `string?` | null | CSS class attribute for the BitChoiceGroup item. | | Id | `string?` | null | Id attribute of the BitChoiceGroup item. | | IsEnabled | `bool` | true | Whether the BitChoiceGroup item is enabled. | | Icon | `BitIconInfo?` | null | The icon to show as content of the BitChoiceGroup item. Takes precedence over IconName when both are set. | | IconName | `string?` | null | The icon name (built-in Fluent UI) to show as content of the BitChoiceGroup item. | | ImageSrc | `string?` | null | The image address to show as the content of the BitChoiceGroup item. | | ImageAlt | `string?` | null | The alt attribute for the image of the BitChoiceGroup item. | | ImageSize | `BitImageSize?` | null | Provides Width and Height for the image of the BitChoiceGroup item. | | Prefix | `string?` | null | The text to show as a prefix for the BitChoiceGroup item. | | SelectedImageSrc | `string?` | null | Provides a new image for the selected state of the image of the BitChoiceGroup item. | | Style | `string?` | null | CSS style attribute for the BitChoiceGroup item. | | Template | `RenderFragment<BitChoiceGroupItem<TValue>>?` | null | The custom template for the BitChoiceGroup item. | | Text | `string?` | null | Text to show as the content of BitChoiceGroup item. | | Value | `string?` | null | The value returned when BitChoiceGroup item is checked. | | Index | `int` | null | Index of the BitChoiceGroup item. This property's value is set by the component at render. | | IsSelected | `bool` | false | Determines if the item is selected. This property's value is assigned by the component. | ### BitChoiceGroupOption Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | AriaLabel | `string?` | null | AriaLabel attribute for the BitChoiceGroup option. | | Class | `string?` | null | CSS class attribute for the BitChoiceGroup option. | | Id | `string?` | null | Id attribute of the BitChoiceGroup option. | | IsEnabled | `bool` | true | Whether the BitChoiceGroup option is enabled. | | Icon | `BitIconInfo?` | null | The icon to show as content of the BitChoiceGroup option. Takes precedence over IconName when both are set. | | IconName | `string?` | null | The icon name (built-in Fluent UI) to show as content of the BitChoiceGroup option. | | ImageSrc | `string?` | null | The image address to show as the content of the BitChoiceGroup option. | | ImageAlt | `string?` | null | The alt attribute for the image of the BitChoiceGroup option. | | ImageSize | `BitImageSize?` | null | Provides Width and Height for the image of the BitChoiceGroup option. | | Prefix | `string?` | null | The text to show as a prefix for the BitChoiceGroup option. | | SelectedImageSrc | `string?` | null | Provides a new image for the selected state of the image of the BitChoiceGroup option. | | Style | `string?` | null | CSS style attribute for the BitChoiceGroup option. | | Template | `RenderFragment<BitChoiceGroupOption<TValue>>?` | null | The custom template for the BitChoiceGroup option. | | Text | `string?` | null | Text to show as the content of BitChoiceGroup option. | | Value | `string?` | null | The value returned when BitChoiceGroup option is checked. | | Index | `int` | null | Index of the BitChoiceGroup option. This property's value is set by the component at render. | | IsSelected | `bool` | false | Determines if the option is selected. This property's value is assigned by the component. | ### BitChoiceGroupNameSelectors<TItem, TValue> Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | AriaLabel | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.AriaLabel)) | AriaLabel attribute for the BitChoiceGroup option. | | Class | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.Class)) | CSS class attribute for the BitChoiceGroup option. | | Id | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.Id)) | Id attribute of the BitChoiceGroup option. | | IsEnabled | `BitNameSelectorPair<TItem, bool>` | new(nameof(BitChoiceGroupItem<TValue>.IsEnabled)) | Whether the BitChoiceGroup option is enabled. | | Icon | `BitNameSelectorPair<TItem, BitIconInfo?>` | new(nameof(BitChoiceGroupItem<TValue>.Icon)) | Icon field name and selector of the custom input class. | | IconName | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.IconName)) | IconName field name and selector of the custom input class. | | ImageSrc | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.ImageSrc)) | The image address to show as the content of the BitChoiceGroup option. | | ImageAlt | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.ImageAlt)) | The alt attribute for the image of the BitChoiceGroup option. | | ImageSize | `BitNameSelectorPair<TItem, BitImageSize?>` | new(nameof(BitChoiceGroupItem<TValue>.ImageSize)) | Provides Width and Height for the image of the BitChoiceGroup option. | | SelectedImageSrc | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.SelectedImageSrc)) | Provides a new image for the selected state of the image of the BitChoiceGroup option. | | Style | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.Style)) | CSS style attribute for the BitChoiceGroup option. | | Template | `BitNameSelectorPair<TItem, RenderFragment<TItem>?>` | new(nameof(BitChoiceGroupItem<TValue>.Template)) | Template field name and selector of the custom input class. | | Text | `BitNameSelectorPair<TItem, string?>` | new(nameof(BitChoiceGroupItem<TValue>.Text)) | Text to show as the content of BitChoiceGroup option. | | Value | `BitNameSelectorPair<TItem, TValue?>` | new(nameof(BitChoiceGroupItem<TValue>.Value)) | The value returned when BitChoiceGroup option is checked. | | Index | `string` | nameof(BitChoiceGroupItem<TValue>.Index)) | The Index field name of the custom input class. This property's value is set by the component at render. | | IsSelected | `string` | nameof(BitChoiceGroupItem<TValue>.IsSelected)) | The IsSelected field name of the custom input class. This property's value is assigned by the component. | ### BitChoiceGroupClassStyles Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Root | `string?` | null | Custom CSS classes/styles for the root element of the BitChoiceGroup. | | LabelContainer | `string?` | null | Custom CSS classes/styles for the label container of the BitChoiceGroup. | | Label | `string?` | null | Custom CSS classes/styles for the label of the BitChoiceGroup. | | Container | `string?` | null | Custom CSS classes/styles for the container of the BitChoiceGroup. | | ItemChecked | `string?` | null | Custom CSS classes/styles for the checked item of the BitChoiceGroup. | | ItemContainer | `string?` | null | Custom CSS classes/styles for the container of each item of the BitChoiceGroup. | | ItemLabel | `string?` | null | Custom CSS classes/styles for the label of each item of the BitChoiceGroup. | | ItemImageContainer | `string?` | null | Custom CSS classes/styles for the image container of each item of the BitChoiceGroup. | | ItemImageWrapper | `string?` | null | Custom CSS classes/styles for the image wrapper of each item of the BitChoiceGroup. | | ItemRadioButton | `string?` | null | Custom CSS classes/styles for the radio button of each item of the BitChoiceGroup. | | ItemImage | `string?` | null | Custom CSS classes/styles for the image of each item of the BitChoiceGroup. | | ItemIconWrapper | `string?` | null | Custom CSS classes/styles for the icon wrapper of each item of the BitChoiceGroup. | | ItemIcon | `string?` | null | Custom CSS classes/styles for the icon of each item of the BitChoiceGroup. | | ItemPrefix | `string?` | null | Custom CSS classes/styles for the prefix of each item of the BitChoiceGroup. | | ItemTextWrapper | `string?` | null | Custom CSS classes/styles for the text wrapper of each item of the BitChoiceGroup. | | ItemText | `string?` | null | Custom CSS classes/styles for the text of each item of the BitChoiceGroup. | ### BitIconInfo Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Name | `string?` | null | Gets or sets the name of the icon. | | BaseClass | `string?` | null | Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty. | | Prefix | `string?` | null | Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty. | ## Examples