Use radio buttons when you have a group of mutually exclusive choices and only one selection from the group is allowed.
Error
Set manually the field in 'error' state.
The Field need to receive a cascaded EditContext. The Error and ValidationMessage will be manage automatically by the EditContext.
Type | Default Value |
---|
bool | false |
<NVFieldRadioGroup Label="Error" @bind-Value="model.Error">
<NVFieldRadio
Label="Error 1"
Value="1"
Error
/>
<NVFieldRadio
Label="Error 2"
Value="2"
Error
/>
<NVFieldRadio
Label="Error 3"
Value="3"
Error
/>
</NVFieldRadioGroup>
<div class="nv-field-radio-group">
<label class="nv-field-label">Error</label>
<div class="nv-field-input">
<div class="nv-field-input">
<div class="nv-field-subfields">
<div class="nv-field nv-field-radio nv-field-error">
<label for="hash-1" class="nv-field-label">Error 1</label>
<div class="nv-field-input">
<input id="hash-1" name="Error" autocomplete="off" type="radio" value="1" checked>
</div>
</div>
<div class="nv-field nv-field-radio nv-field-error">
<label for="hash-2" class="nv-field-label">Error 2</label>
<div class="nv-field-input">
<input id="hash-2" name="Error" autocomplete="off" type="radio" value="2">
</div>
</div>
<div class="nv-field nv-field-radio nv-field-error">
<label for="hash-3" class="nv-field-label">Error 3</label>
<div class="nv-field-input">
<input id="hash-3" name="Error" autocomplete="off" type="radio" value="3">
</div>
</div>
</div>
</div>
</div>
</div>
<nv-fieldradiogroup label="Error">
<nv-fieldradio value="1" label="Error 1" error></nv-fieldradio>
<nv-fieldradio value="2" label="Error 2" error></nv-fieldradio>
<nv-fieldradio value="3" label="Error 3" error></nv-fieldradio>
</nv-fieldradiogroup>
<NvFieldRadioGroup label="Error">
<NvFieldRadio error label="Error 1" value="1" />
<NvFieldRadio error label="Error 2" value="2" />
<NvFieldRadio error label="Error 3" value="3" />
</NvFieldRadioGroup>
Label
Label define the label value of the Radio Field.
Type | Default Value |
---|
string | null |
<NVFieldRadio Name="Label" Label="This is a label"/>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="Label">This is a label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="Label" name="Label">
</div>
</div>
<nv-fieldradio name="Label" label="This is a label"></nv-fieldradio>
<NvFieldRadio label="This is a label" name="Label" />
LabelBefore
Type | Default Value |
---|
bool | false |
<NVFieldRadio Name="LabelBefore" Label="This is a label" LabelBefore/>
<div class="nv-field nv-field-radio nv-field-label-before">
<label class="nv-field-label" for="LabelBefore">This is a label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="LabelBefore" name="LabelBefore">
</div>
</div>
<nv-fieldradio labelbefore name="LabelBefore" label="This is a label"></nv-fieldradio>
<NvFieldRadio label="This is a label" labelBefore name="LabelBefore" />
LabelBeforeWidth
Type | Default Value |
---|
string | null |
<NVFieldRadio Name="LabelBeforeWidth" Label="This is a label" LabelBefore LabelBeforeWidth="250px"/>
<div class="nv-field nv-field-radio nv-field-label-before">
<label class="nv-field-label" for="LabelBeforeWidth" style="width: 250px">This is a label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="LabelBeforeWidth" name="LabelBeforeWidth">
</div>
</div>
<nv-fieldradio name="LabelBeforeWidth" label="This is a label"
labelbefore labelbeforewidth="250px"></nv-fieldradio>
<NvFieldRadio label="This is a label" labelBefore labelBeforeWidth="250px" name="LabelBeforeWidth" />
Message
Message define a 'hint ' message for the Radio Field.
Type | Default Value |
---|
string | null |
<NVFieldRadio Label="Message" Message="This is a message"/>
<div class="nv-field nv-field-radio">
<label for="Message" class="nv-field-label">Message</label>
<div class="nv-field-input">
<input id="Message" Name="Message" autocomplete="off" type="radio">
</div>
<div class="nv-field-message">
<div>This is a message</div>
</div>
</div>
<nv-fieldradio label="Message" message="This is a message"></nv-fieldradio>
<NvFieldRadio label="Message" message="This is a message" />
Name
Name defined the RadioInputGroup associated to the value when checked.
If you do not pass a Name to the FieldRadio, the name will be provided by the FieldRadioContext provided by the FieldRadioGroup.
Type | Default Value |
---|
string | null |
<EditForm Model="model">
<DataAnnotationsValidator />
<NVFieldRadioGroup Label="FirstUniqueName" @bind-Value="model.FirstUniqueName">
// the Name will be provided by the FieldRadioContext cascaded by the FieldRadioGroup.
// Here from FieldIdentifier.FieldName -> FirstUniqueName
<NVFieldRadio Label="First label" Value="1"/>
<NVFieldRadio Label="Second label" Value="2"/>
<NVFieldRadio Label="Third label" Value="3"/>
</NVFieldRadioGroup>
// the Name will be provided by the FieldRadioContext cascaded by the FieldRadioGroup.
// Here from Name -> MySecondUniqueName
<NVFieldRadioGroup Name="MySecondUniqueName" @bind-Value="model.SecondUniqueName" MT="8">
<NVFieldRadio Label="First label" Value="1"/>
<NVFieldRadio Label="Second label" Value="2"/>
<NVFieldRadio Label="Third label" Value="3"/>
</NVFieldRadioGroup>
</EditForm>
// the Name will be provided by the FieldRadioContext cascaded by the FieldRadioGroup.
// Here from _autoname -> an hash string computed on the instantiation of the component.
<NVFieldRadioGroup @bind-Value="model.ThirdUniqueName" MT="8">
<NVFieldRadio Label="First label" Value="1"/>
<NVFieldRadio Label="Second label" Value="2"/>
<NVFieldRadio Label="Third label" Value="3"/>
</NVFieldRadioGroup>
<form>
<div class="nv-field nv-field-radio-group">
<label class="nv-field-label">FirstUniqueName</label>
<div class="nv-field-input">
<div class="nv-field-subfields">
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-11">First label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-11" name="FirstUniqueName" value="1">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-22">Second label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-22" name="FirstUniqueName" value="2">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-33">Third label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-33" name="FirstUniqueName" value="3">
</div>
</div>
</div>
</div>
</div>
<div class="nv-field nv-field-radio-group mt-8">
<label class="nv-field-label">MySecondUniqueName</label>
<div class="nv-field-input">
<div class="nv-field-subfields">
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-44">First label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-44" name="MySecondUniqueName" value="1">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-55">Second label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-55" name="MySecondUniqueName" value="2">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-66">Third label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-66" name="MySecondUniqueName" value="3">
</div>
</div>
</div>
</div>
</div>
</form>
<div class="nv-field nv-field-radio-group mt-8">
<label class="nv-field-label">MySecondUniqueName</label>
<div class="nv-field-input">
<div class="nv-field-subfields">
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-77">First label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-77" name="autoname-ThirdUniqueName" value="1">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-88">Second label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-88" name="autoname-ThirdUniqueName" value="2">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-99">Third label</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-99" name="autoname-ThirdUniqueName" value="3">
</div>
</div>
</div>
</div>
</div>
NVFieldAfter
Add content after the 'input' element.
Type | Default Value |
---|
RenderFragment | null |
<NVFieldRadio Name="FieldAfter" Label="FieldAfter">
<NVFieldAfter>
<NVText Size="xs" MT="2" TextColor="blue" Width="50%">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.
</NVText>
</NVFieldAfter>
</NVFieldRadio>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="FieldAfter">FieldAfter</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="FieldAfter" name="FieldAfter">
</div>
<div class="nv-field-input-plugin">
<p class="nv-text font-normal text-xs mt-2" style="color:blue; width:50%">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.</p>
</div>
</div>
<nv-fieldradio label="FieldAfter" name="FieldAfter">
<div slot="after">
<nv-text size="xs" mt="2" color="blue" width="50%">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.
</nv-text>
</div>
</nv-fieldradio>
<NvFieldRadio label="FieldAfter" name="FieldAfter">
<div slot="after">
<NvText size="xs" mt="2" color="blue" width="50%">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.
</NvText>
</div>
</NvFieldRadio>
NVFieldBefore
Add content before the 'input' element.
Type | Default Value |
---|
RenderFragment | null |
<NVFieldRadio Name="FieldBefore" Label="FieldBefore">
<NVFieldBefore>
<NVText Size="xs" MB="2" TextColor="blue" Width="50%">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.
</NVText>
</NVFieldBefore>
</NVFieldRadio>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="FieldBefore">FieldBefore</label>
<div class="nv-field-input-plugin">
<p class="nv-text font-normal text-xs mb-2" style="color:blue; width:50%">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.</p>
</div>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="FieldBefore" name="FieldBefore">
</div>
</div>
<nv-fieldradio label="FieldBefore" name="FieldBefore">
<div slot="before">
<nv-text size="xs" mb="2" color="blue" width="50%">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.
</nv-text>
</div>
</nv-fieldradio>
<NvFieldRadio label="FieldBefore" name="FieldBefore">
<div slot="before">
<NvText size="xs" mb="2" color="blue" width="50%">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et ex nunc.</NvText>
</div>
</NvFieldRadio>
NVFieldLabel
NVFieldLabel define the content of the label of the Radio Field.
Type | Default Value |
---|
RenderFragment | null |
<NVFieldRadio Name="FieldLabel">
<NVFieldLabel>
This is a <NVBlock Tag="strong" TextColor="error">label</NVBlock>
</NVFieldLabel>
</NVFieldRadio>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="FieldLabel">
This is a <strong class="text-error">label</strong>
</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="FieldLabel" name="FieldLabel">
</div>
</div>
<nv-fieldradio name="FielLabel">
<div slot="label"> This is a <nv-block tag="strong" textcolor="error">label</nv-block>
</div>
</nv-fieldradio>
<NvFieldRadio name="FielLabel">
<div slot="label"> This is a <NvBlock tag="strong" textColor="error"> label </NvBlock>
</div>
</NvFieldRadio>
NVFieldMessage
Label define the content of the label of the Radio Field.
Type | Default Value |
---|
RenderFragment | null |
<NVFieldRadio Name="FieldMessage" Label="FieldMessage">
<NVFieldMessage>
This is a <NVBlock Tag="strong" TextColor="error">message</NVBlock>
</NVFieldMessage>
</NVFieldRadio>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="FieldMessage">
FieldMessage
</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="FieldMessage" name="FieldMessage">
</div>
<div class="nv-field-message">
<div>
This is a <strong style="color:red">message</strong>
</div>
</div>
</div>
<nv-fieldradio label="FieldMessage" name= "FieldMessage">
<div slot="label"> This is a <nv-block tag="strong" textcolor="error">message</nv-block>
</div>
</nv-fieldradio>
<NvFieldRadio label="Field Message" name= "FieldMessage">
<div slot="label"> This is a <NvBlock tag="strong" textColor="error"> message </NvBlock>
</div>
</NvFieldRadio>
Success
Set the field in State 'success'.
Type | Default Value |
---|
bool | false |
<NVFieldRadioGroup Label="Success" @bind-Value="model.Success">
<NVFieldRadio
Label="Success 1"
Value="1"
Success
/>
<NVFieldRadio
Label="Success 2"
Value="2"
/>
<NVFieldRadio
Label="Success 3"
Value="3"
/>
</NVFieldRadioGroup>
<div class="nv-field-radio-group">
<label class="nv-field-label">Error</label>
<div class="nv-field-input">
<div class="nv-field-subfields">
<div class="nv-field nv-field-radio nv-field-success">
<label for="success-1" class="nv-field-label">Success 1</label>
<div class="nv-field-input">
<input id="success-1" name="Error" autocomplete="off" type="radio" value="1" checked>
</div>
</div>
<div class="nv-field nv-field-radio">
<label for="success-2" class="nv-field-label">Success 2</label>
<div class="nv-field-input">
<input id="success-2" name="Error" autocomplete="off" type="radio" value="2">
</div>
</div>
<div class="nv-field nv-field-radio">
<label for="success-3" class="nv-field-label">Success 3</label>
<div class="nv-field-input">
<input id="success-3" name="Error" autocomplete="off" type="radio" value="3">
</div>
</div>
</div>
</div>
</div>
<nv-fieldradiogroup label="Success">
<nv-fieldradio value="1" label="Success 1" success></nv-fieldradio>
<nv-fieldradio value="2" label="Success 2" success></nv-fieldradio>
<nv-fieldradio value="3" label="Success 3" success></nv-fieldradio>
</nv-fieldradiogroup>
<NvFieldRadioGroup label="Success">
<NvFieldRadio label="Success 1" success value="1" />
<NvFieldRadio label="Success 2" success value="2" />
<NvFieldRadio label="Success 3" success value="3" />
</NvFieldRadioGroup>
Value
Set the value of the radio button. When the radio is checked, this Value will be assigned to the RadioGroup Value
Type | Default Value |
---|
T (generic type) | null |
<NVFieldRadioGroup Label="_value" @bind-Value="_value">
<NVFieldRadio Label="Value 1" Value="@(1)"/>
<NVFieldRadio Label="Value 2" Value="@(2)"/>
<NVFieldRadio Label="Value 3" Value="@(3)"/>
</NVFieldRadioGroup>
@code {
private int _value = 1;
}
<div class="nv-field nv-field-radio-group">
<label class="nv-field-label" for="hash-value1">_value</label>
<div class="nv-field-input">
<div class="nv-field-subfields">
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-value1">Value 1</label>
<div class="nv-field-input">
<input checked="checked" autocomplete="off" type="radio" id="hash-value1" name="Value">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-value2">Value 2</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-value2" name="Value">
</div>
</div>
<div class="nv-field nv-field-radio">
<label class="nv-field-label" for="hash-value3">Value 3</label>
<div class="nv-field-input">
<input autocomplete="off" type="radio" id="hash-value3" name="Value">
</div>
</div>
</div>
</div>
</div>
<nv-fieldradiogroup label="_value" value="1">
<nv-fieldradio value="1" label="Value 1"></nv-fieldradio>
<nv-fieldradio value="2" label="Value 2"></nv-fieldradio>
<nv-fieldradio value="3" label="Value 3"></nv-fieldradio>
</nv-fieldradiogroup>
<NvFieldRadioGroup label="_value" value="1">
<NvFieldRadio value="1" label="Value 1" />
<NvFieldRadio value="2" label="Value 2" />
<NvFieldRadio value="3" label="Value 3" />
</NvFieldRadioGroup>