RadioButton

in namespace DotVVM.Bootstrap5.Controls

Extends the default RadioButton control with additional Bootstrap features.

Usage & Scenarios

Extends the builtin RadioButton control with Bootstrap CSS styles.

If you want to use this control inside ButtonGroup, use ButtonGroupRadioButton instead.

https://getbootstrap.com/docs/5.2/forms/checks-radios

Sample 1: Inline RadioButtons

The IsInline property allows to render checkboxes on one row.

Use the RenderLabel property to set whether the label should be rendered. If not set, the label will be rendered only when needed.

<bs:RadioButton Text="RadioButton 1" GroupName="RadioButtons" 
                CheckedValue="RadioButton 1" CheckedItem="{value: Radio}" 
                IsInline="true" />
<bs:RadioButton Text="RadioButton 2" GroupName="RadioButtons" 
                CheckedValue="RadioButton 2" CheckedItem="{value: Radio}"
                IsInline="true" />
public class ViewModel : DotvvmViewModelBase
{
    public string Radio { get; set; }
}

Sample 2: RadioButton VisualStyle

Except the Default radio button visual style, there are Switch and Button visual styles.

<h2>Button type</h2>
<bs:RadioButton CheckedValue="{value: true}" Checked="{value: Checked}" Text="Primary" VisualStyle="Button" ButtonType="Primary" IsInline="true" />
<bs:RadioButton CheckedValue="{value: false}" Checked="{value: Checked}" Text="Secondary" VisualStyle="Button" ButtonType="Secondary" IsInline="true" />
<bs:RadioButton CheckedValue="{value: false}" Checked="{value: Checked}" Text="Danger" VisualStyle="Button" ButtonType="Danger" IsInline="true" />
{{value: Checked}}
<hr/>

<h2>Switch type</h2>
<bs:RadioButton GroupName="RadioButton" VisualStyle="Switch" CheckedValue="true" Text="Switch RadioButton"/>
<hr/>
public class ViewModel : DotvvmViewModelBase
{
    public bool Checked { get; set; }
}

Properties

Name Type Description Notes Default Value
property icon ButtonFontType ButtonTextColor Gets or sets the font color. Use this property in combination with a `Button` radio button visual style.
attribute
inner element
static value
bindable
default
Default
property icon ButtonSize Size Gets or sets the button size. Use this property in combination with a `Button` radio button visual style.
attribute
inner element
static value
bindable
default
Default
property icon ButtonType ButtonType Gets or sets the button type. Use this property in combination with a `Button` radio button visual style.
attribute
inner element
static value
bindable
default
Primary
property icon ButtonVisualStyle ButtonVisualStyle Gets or sets the button visual style. Use this property in combination with a `Button` radio button visual style.
attribute
inner element
static value
bindable
default
SolidFill
property icon Checked Boolean? Gets or sets whether the control is checked.
attribute
inner element
static value
bindable
default
null
property icon CheckedItem IValueBinding<Object> Gets or sets the checked item. Use this property in combination with the CheckedValue property.
attribute
inner element
static value
bindable
default
null
property icon CheckedValue Object Gets or sets the value that will be used as a result when the control is checked. Use this property in combination with the CheckedItem property.
attribute
inner element
static value
bindable
default
null
property icon Content List<DotvvmControl> Gets or sets the content placed inside the control.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets a value indicating whether the control is enabled and can be clicked on.
attribute
inner element
static value
bindable
default
null
property icon GroupName String Gets or sets a unique name of the radio button group.
attribute
inner element
static value
bindable
default
null
property icon IsInline Boolean Gets or sets whether the control should be rendered on the same horizontal row.
attribute
inner element
static value
bindable
default
False
property icon IsReversed Boolean Gets or sets whether the control should be put on the opposite side of the page.
attribute
inner element
static value
bindable
default
False
property icon RenderLabel Boolean Gets or sets whether the label will be rendered. If set to null than the label will be rendered if needed.
attribute
inner element
static value
bindable
default
True
property icon Text String Gets or sets the text inside the control.
attribute
inner element
static value
bindable
default
null
property icon Visible Boolean Gets or sets whether the control is visible. When set to false, `style="display: none"` will be added to this control.
attribute
inner element
static value
bindable
default
True
property icon VisualStyle CheckBoxVisualStyle Gets or sets the radio button visual style. Possible values are `Default`, `Switch`, `Button`.
attribute
inner element
static value
bindable
default
Default

Events

Name Type Description
event icon Changed ICommandBinding Gets or sets the command that will be triggered when the control check state is changed.

HTML produced by the control