RadioButton

in namespace DotVVM.Controls.Tailwind.Controls

Renders a custom radio button with a hidden native input and custom visual circle.

Usage & Scenarios

The RadioButton control renders a Tailwind-styled radio input. Bind the selected value with CheckedItem and specify the option value with CheckedValue.

Sample 1: Radio Group

Group radio buttons by binding them to the same CheckedItem. This sample also shows GroupName, custom content, Enabled, and the Changed command.

<div class="space-y-2">
    <t:RadioButton Text="Email"
                   CheckedValue="email"
                   CheckedItem="{value: ContactMethod}"
                   GroupName="contact-method"
                   Changed="{command: IncrementChanges()}" />

    <t:RadioButton Text="Phone"
                   CheckedValue="phone"
                   CheckedItem="{value: ContactMethod}"
                   GroupName="contact-method" />

    <t:RadioButton CheckedValue="chat"
                   CheckedItem="{value: ContactMethod}"
                   GroupName="contact-method">
        <span>Team chat <strong>(recommended)</strong></span>
    </t:RadioButton>

    <t:RadioButton Text="Disabled option"
                   CheckedValue="mail"
                   CheckedItem="{value: ContactMethod}"
                   GroupName="contact-method"
                   Enabled="false" />
</div>

<p>Selected contact method: <strong>{{value: ContactMethod}}</strong></p>
<p><code>Changed</code> command count: <strong>{{value: ChangeCount}}</strong></p>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.tailwind.RadioButton.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string ContactMethod { get; set; } = "email";

        public int ChangeCount { get; set; }

        public void IncrementChanges()
        {
            ChangeCount++;
        }
    }
}

Properties

Name Type Description Notes Default Value
property icon CheckedItem IValueBinding Binds the selected value for the radio group.
attribute
inner element
static value
bindable
default
null
property icon CheckedValue Object Specifies the value represented by this radio button.
attribute
inner element
static value
bindable
default
null
property icon Content List<DotvvmControl> Gets or sets custom label content rendered next to the radio button. Cannot be combined with Text.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Controls whether the radio button can be interacted with.
attribute
inner element
static value
bindable
default
True
property icon GroupName String Specifies the name attribute of the radio input, used to group radio buttons together.
attribute
inner element
static value
bindable
default
null
property icon Text String Gets or sets the plain-text label rendered next to the radio button. Cannot be combined with Content.
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

Events

Name Type Description
event icon Changed ICommandBinding Runs after the selected value changes.

HTML produced by the control