Label
Note:
you normally wouldn't use the Label component on its own,
it's typically used as part of a bigger component, like a text input
Read more about the label component on the Gov.UK Design System website
@using GovUkDesignSystemDotNet
@await Html.GovUkLabel(new LabelViewModel
{
HtmlOrText = new HtmlOrText("Email address"),
For = "name-of-email-address-input-element"
})
Options
| Name | Type | Description |
|---|---|---|
| HtmlOrText | HtmlOrText | Required. HTML or text to use within the label. |
| For | string |
The value of the for attribute,
the ID of the input the label is associated with.
|
| IsPageHeading | bool | Whether the label also acts as the heading for the page. |
| Classes | List<string> | Classes to add to the label tag. |
| Attributes | Dictionary<string, string> | HTML attributes (for example data attributes) to add to the label tag. |
Examples
Using IsPageHeading
@using GovUkDesignSystemDotNet
@await Html.GovUkLabel(new LabelViewModel
{
HtmlOrText = new HtmlOrText("Email address"),
For = "name-of-email-address-input-element",
IsPageHeading = true,
Classes = ["govuk-label--l"]
})