Skip to main content

This is a new service.

Fieldset

Read more about the fieldset component on the Gov.UK Design System website

@using GovUkDesignSystemDotNet

@await Html.GovUkFieldset(new FieldsetViewModel
{
    Legend = new FieldsetLegendViewModel
    {
        HtmlOrText = new HtmlOrText("What is your address?"),
        Classes = ["govuk-fieldset__legend--l"],
        IsPageHeading = true
    },
    HtmlOrText = new HtmlOrText(
        @<text>
             @await Html.GovUkTextInput(new TextInputViewModel
                 {
                     Name = "address-line-1",
                     Label = new LabelViewModel
                     {
                         HtmlOrText = new HtmlOrText("Address line 1")
                     }
                 })
             @await Html.GovUkTextInput(new TextInputViewModel
                 {
                     Name = "town-city",
                     Label = new LabelViewModel
                     {
                         HtmlOrText = new HtmlOrText("Town or city")
                     }
                 })
             @await Html.GovUkTextInput(new TextInputViewModel
                 {
                     Name = "postcode",
                     Label = new LabelViewModel
                     {
                         HtmlOrText = new HtmlOrText("Postcode")
                     }
                 })
         </text>)
})

Options

Options for FieldsetViewModel
Name Type Description
DescribedBy List<string> One or more element IDs to add to the input aria-describedby attribute, used to provide additional descriptive information for screenreader users.
Legend FieldsetLegendViewModel The legend for the fieldset component. See options for FieldsetLegendViewModel
Classes List<string> Classes to add to the fieldset container.
Role string Optional ARIA role attribute.
Attributes Dictionary<string, string> HTML attributes (for example data attributes) to add to the fieldset container.
HtmlOrText HtmlOrText HTML or text to use/render within the fieldset element.
Options for FieldsetLegendViewModel
Name Type Description
HtmlOrText HtmlOrText Required. HTML or text to use within the legend.
Classes List<string> Classes to add to the legend.
IsPageHeading bool Whether the legend also acts as the heading for the page.