ButtonGroup Blazor API

ButtonGroup Properties

NameTypeDefaultDescription
DataSourceobject[]Configures the set of buttons to be displayed. The dataSource property accepts multiple formats: it can be an array of strings or numbers—each representing a button—or an array of objects, where each object defines the properties of a button (for example, with attributes such as label for the button text and value for its underlying value). Alternatively, dataSource can be a function (callback) that returns an array in either of these formats. This flexibility allows you to define button configurations statically or generate them dynamically based on custom logic.
SelectionModeButtonGroupSelectionModeButtonGroupSelectionMode.OneSpecifies how items within the element can be selected—for example, allowing single selection, multiple selections, or no selection at all.
DisabledboolfalseSpecifies whether the element is interactive and can be used by the user. When enabled, the element responds to user input; when disabled, the element is non-interactive and usually appears visually distinct to indicate it is unavailable.
UnlockKeystring""Defines or retrieves the unlockKey, a unique identifier or code required to activate and gain access to the product’s full features.
Localestring"en"Specifies or retrieves the currently selected language for the component. This property works together with messages, which provides the corresponding localized texts or translations for each available language. Changing the language will update the displayed messages based on the selected locale.
MessagesobjectN/ADefines or retrieves an object containing text strings used within the widget, allowing these strings to be localized for different languages. This property works in conjunction with the locale property to provide translated text for the widget's user interface, enabling support for internationalization.
Namestring""Sets or retrieves the value of the element's name attribute. The name attribute is used to identify form fields when submitting an HTML form, allowing the form data to be sent as key-value pairs to the server. This attribute is essential for grouping related input elements and accessing their submitted values on the server side.
ReadonlyboolfalseWhen the custom element has the 'readonly' attribute set, its value cannot be modified by the user. Interaction methods such as typing, selecting, or altering content are disabled; however, users are still able to focus on and copy content from the element if desired. Any attempts to change the value—either via keyboard, mouse, or programmatic user actions—will have no effect.
RightToLeftboolfalseGets or sets a value that determines whether the element’s layout and text direction are aligned for right-to-left (RTL) locales, such as those using Arabic or Hebrew scripts. When enabled, this property ensures proper alignment and rendering for languages that read from right to left."
Themestring""Specifies the visual theme to be applied to the element. The theme controls the overall appearance, including colors, typography, and style variations, ensuring the element is displayed consistently according to the selected design.
SelectedValuesstring[]new string[]{}Gets or sets the selected values of the button group component as an array of strings. Each string in the array corresponds to the value attribute of a selected button within the group. This property can be used to programmatically read which buttons are currently selected or to define the initial selection state.
SelectedIndexesint[]new int[]{}Gets or sets the indexes of the selected buttons within the group as an array of numbers. Each number corresponds to the zero-based index of a selected button. Used to track multiple selected buttons within the group.
UnfocusableboolfalseIf set to true, this property prevents the element from receiving keyboard focus, making it unreachable via keyboard navigation (such as the Tab key).

ButtonGroup Methods

NameTypeArgumentsDescription
GetDataSourceAsync()Task<IEnumerable<object>>'N/A'Gets the &quot;DataSource&quot; property as Task&lt;IEnumerable&lt;object&gt;&gt;.
GetSelectedIndexesAsync()Task<int[]>'N/A'Gets the &quot;SelectedIndexes&quot; property as Task&lt;int[]&gt;.
GetSelectedValuesAsync()Task<string[]>'N/A'Gets the &quot;SelectedValues&quot; property as Task&lt;string[]&gt;.
Refreshvoid'N/A'Refreshes the Blazor Component. Performs a layout of the HTML Elements and recalculates the measurements.
Rendervoid'N/A'Re-renders the Blazor Component. This method will make a full re-render.
Selectvoidobject valueToggles the selection state of an item within the element, allowing users to either select or deselect the specified item based on its current state.Args: object value - The index or the value of the item to be selected/unselected.
Selectvoidint valueToggles the selection state of an item within the element, allowing users to either select or deselect the specified item based on its current state.Args: int value - The index or the value of the item to be selected/unselected.
Selectvoidstring valueToggles the selection state of an item within the element, allowing users to either select or deselect the specified item based on its current state.Args: string value - The index or the value of the item to be selected/unselected.
StateHasChangedvoid'N/A'Refreshes the state and Re-renders the Blazor Component, if necessary.

ButtonGroup Events

NameTypeDescriptionEvent Detail
OnChangeEventCallback<Event>The "change" event is triggered whenever the values of selectedValues or selectedIndexes are updated. This event occurs whenever the user selects or deselects an option, or when the selection state is modified programmatically. Use this event to respond to changes in the selection, such as updating the UI or performing validation.N/A
Changedevent ButtonGroupChangedEventHandlerThe "change" event is triggered whenever the values of selectedValues or selectedIndexes are updated. This event occurs whenever the user selects or deselects an option, or when the selection state is modified programmatically. Use this event to respond to changes in the selection, such as updating the UI or performing validation.ButtonGroupChangedEventArgs

Enums

ButtonGroupSelectionMode

ButtonGroupSelectionMode.None
ButtonGroupSelectionMode.One
ButtonGroupSelectionMode.ZeroOrOne
ButtonGroupSelectionMode.ZeroOrMany