Fieldset
Groups related fields under a legend.
An interactive page: C# runs over a Blazor Server connection.
Groups related fields under a heading, such as a shipping address.
Usage
<Fieldset Label="Shipping address" Description="Where we send your order.">
<TextField @bind-Value="Model.Street" /> ...
</Fieldset>Label and description
Use Label for the group's heading and Description for a line under it, which screen readers can read with the group's name.
Preview
Code
System.ComponentModel.DataAnnotations
<Form Model="Model" FormName="fieldset-address" MaxWidth="28.Rem" Grow>
<Fieldset Label="Shipping address" Description="Where we send your order.">
<TextField @bind-Value="Model!.Street" AutoComplete="street-address" />
<Row Gap="3">
<TextField @bind-Value="Model!.City" AutoComplete="address-level2" Grow />
<TextField @bind-Value="Model!.PostalCode" AutoComplete="postal-code" MaxWidth="9.Rem" />
</Row>
</Fieldset>
</Form>
{
[SupplyParameterFromForm(FormName = "fieldset-address")]
private Order? Model { get; set; }
protected override void OnInitialized() => Model ??= new();
public sealed class Order
{
[Required]
public string? Street { get; set; } = "221B Baker Street";
[Required]
public string? City { get; set; } = "London";
[Required, Display(Name = "Postal code"), StringLength(10)]
public string? PostalCode { get; set; } = "NW1 6XE";
}
}Columns
Use Columns to lay the group's fields out side by side, by the group's own width.
Preview
Code
System.ComponentModel.DataAnnotations
<Form Model="Model" FormName="fieldset-columns" Grow>
<TextField @bind-Value="Model!.Company" AutoComplete="organization" />
<Fieldset Label="Billing address" Columns="3">
<TextField @bind-Value="Model!.Street" AutoComplete="street-address" ColSpan="GridSpan.Full" />
<TextField @bind-Value="Model!.City" AutoComplete="address-level2" />
<TextField @bind-Value="Model!.Region" AutoComplete="address-level1" />
<TextField @bind-Value="Model!.PostalCode" AutoComplete="postal-code" />
</Fieldset>
</Form>
{
[SupplyParameterFromForm(FormName = "fieldset-columns")]
private Billing? Model { get; set; }
protected override void OnInitialized() => Model ??= new();
public sealed class Billing
{
public string? Company { get; set; } = "Acme Robotics";
public string? Street { get; set; } = "500 Market Street";
public string? City { get; set; } = "San Francisco";
[Display(Name = "State or region")]
public string? Region { get; set; } = "CA";
[Display(Name = "Postal code")]
public string? PostalCode { get; set; } = "94105";
}
}A list of settings
Use Dividers to draw a line between rows, as in a list of settings.
Preview
Code
System.ComponentModel.DataAnnotations
<Form Model="Model" FormName="fieldset-dividers" MaxWidth="32.Rem" Grow>
<Fieldset Label="Privacy" Description="Who can see your profile and activity." Dividers Gap="3">
<Switch @bind-Value="Model!.PublicProfile" ControlPosition="ControlPosition.End"
Hint="Anyone with the link can see your name, photo and bio." />
<Switch @bind-Value="Model!.ShowActivity" ControlPosition="ControlPosition.End"
Hint="Your recent comments and reviews, on your profile." />
<Switch @bind-Value="Model!.Searchable" ControlPosition="ControlPosition.End"
Hint="Teammates can find you by email address." />
</Fieldset>
</Form>
{
[SupplyParameterFromForm(FormName = "fieldset-dividers")]
private Privacy? Model { get; set; }
protected override void OnInitialized() => Model ??= new();
public sealed class Privacy
{
[Display(Name = "Public profile")]
public bool PublicProfile { get; set; } = true;
[Display(Name = "Show my activity")]
public bool ShowActivity { get; set; }
[Display(Name = "Findable by email")]
public bool Searchable { get; set; } = true;
}
}Icons on sections
Use Icon to tell sections apart at a glance; it's decorative.
Preview
Code
System.ComponentModel.DataAnnotations
<Form Model="Model" FormName="fieldset-icons" MaxWidth="32.Rem" Grow>
<Fieldset Label="Notifications" Description="What we email you about." Icon="Lucide.Bell" Dividers Gap="3">
<Switch @bind-Value="Model!.Mentions" ControlPosition="ControlPosition.End" />
<Switch @bind-Value="Model!.Digest" ControlPosition="ControlPosition.End" />
</Fieldset>
<Fieldset Label="Security" Description="How you sign in." Icon="Lucide.Shield" Dividers Gap="3">
<Switch @bind-Value="Model!.TwoFactor" ControlPosition="ControlPosition.End" />
<Switch @bind-Value="Model!.NewDevice" ControlPosition="ControlPosition.End" />
</Fieldset>
</Form>
{
[SupplyParameterFromForm(FormName = "fieldset-icons")]
private Preferences? Model { get; set; }
protected override void OnInitialized() => Model ??= new();
public sealed class Preferences
{
[Display(Name = "Mentions and replies")]
public bool Mentions { get; set; } = true;
[Display(Name = "Weekly digest")]
public bool Digest { get; set; }
[Display(Name = "Two-step sign-in")]
public bool TwoFactor { get; set; } = true;
[Display(Name = "Email me about new devices")]
public bool NewDevice { get; set; } = true;
}
}Mode support
| Feature | Off | Static | Live |
|---|---|---|---|
| Everything | Yes | Yes | Yes |
Off: JavaScript disabled. Static: a static SSR page with IzzyBlazor's script. Live: an interactive page (Server, WebAssembly or Auto).
Accessibility
- It renders a native
fieldsetwithLabelas itslegend, which screen readers announce as the group's name when focus moves into it. - The
Descriptiondescribes the group (aria-describedby), so screen readers can read it with the name; what one field needs still goes in itsHint. - The
Iconis decorative and hidden from screen readers.
Parameters
| Prop | Type | Default |
|---|---|---|
LabelThe group's heading. | string | Required |
IconAn icon at the start of the heading, centered on the label and description, to tell sections apart. | IconData? | |
DescriptionA short explanation under the heading. | string? | |
GapSpace between the fields, in spacing steps. | Responsive<int> | 4 |
ColumnsLays the group's fields out in up to this many columns (1 to 4), by the group's own width, as Columns does. | int | 1 |
DividersDraws a line between the fields, with the Gap above and below it, as in a list of settings. | bool | false |
ChildContentThe fields. | RenderFragment? |
Plus 25 surface props, 16 item props and 4 common props.
Full APISee also
- Form: posts on static pages, validates live on interactive ones.
- Section: a full-width band of a page, such as a hero.
- Card: media, header, body sections, actions and footer.
- CheckboxGroup: several choices as checkboxes.