@page "/"
<h1>Hello, world!</h1>
Welcome to your new app.
<p>You have selected: @Selected?.Label</p>
@foreach (var option in Options)
{
<label class="option @(Selected == option ? "selected" : null)">
<input type="radio" name="Letters" value="@option.Value"
@onchange="@(() => Selected = option)" />
<a>@option.Label</a>
<p>@option.Text</p>
</label>
}
@code {
private RadioOption? Selected { get; set; }
private RadioOption[] Options = new[]
{
new RadioOption
{
Value = "a",
Label = "Letter A",
Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
},
new RadioOption
{
Value = "b",
Label = "Letter B",
Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
},
new RadioOption
{
Value = "c",
Label = "Letter C",
Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
},
new RadioOption
{
Value = "d",
Label = "Letter D",
Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
}
};
class RadioOption
{
public string Label { get; set; }
public string Text { get; set; }
public string Value { get; set; }
}
}