Textarea
Read more about the
textarea
component on the Gov.UK Design System website
@using GovUkDesignSystemDotNet
@await Html.GovUkTextarea(new TextareaViewModel
{
Name = "more-detail",
Label = new LabelViewModel
{
HtmlOrText = new HtmlOrText("Can you provide more detail?"),
IsPageHeading = true,
Classes = ["govuk-label--l"]
},
Hint = new HintViewModel
{
HtmlOrText = new HtmlOrText("Do not include personal or financial information, like your National Insurance number or credit card details")
}
})
Options
Options for TextareaViewModel
|
string
|
The ID of the textarea. Defaults to the value of Name.
|
|
string
|
Required.
The name of the textarea, which is submitted with the form data.
|
|
bool?
|
Optional field to enable or disable the spellcheck attribute on the textarea.
|
|
int?
|
Optional number of textarea rows (default is 5 rows).
|
|
string
|
Optional initial value of the textarea.
|
|
bool
|
If true, textarea will be disabled.
|
|
List<string>
|
One or more element IDs to add to the aria-describedby attribute,
used to provide additional descriptive information for screenreader users.
|
|
LabelViewModel
|
Required.
The label used by the textarea component.
See options for LabelViewModel
|
|
HintViewModel
|
Can be used to add a hint to a textarea component.
See options for HintViewModel
|
|
ErrorMessageViewModel
|
Can be used to add an error message to the textarea component.
The error message component will not display if ErrorMessage is null.
See options for ErrorMessageViewModel
|
|
FormGroupViewModel
|
Additional options for the form group containing the textarea component.
See options for FormGroupViewModel
|
|
List<string>
|
Classes to add to the textarea.
|
|
string
|
Attribute to meet
WCAG success criterion 1.3.5: Identify input purpose,
for instance "bday-day".
See the
Autofill section in the HTML standard
section in the HTML standard for full list of attributes that can be used.
|
|
Dictionary<string, string>
|
HTML attributes (for example, data attributes) to add to the textarea.
|
Examples
Error messages
@using GovUkDesignSystemDotNet
@await Html.GovUkTextarea(new TextareaViewModel
{
Name = "more-detail",
Label = new LabelViewModel
{
HtmlOrText = new HtmlOrText("Can you provide more detail?"),
IsPageHeading = true,
Classes = ["govuk-label--l"]
},
Hint = new HintViewModel
{
HtmlOrText = new HtmlOrText("Do not include personal or financial information, like your National Insurance number or credit card details")
},
ErrorMessage = new ErrorMessageViewModel
{
HtmlOrText = new HtmlOrText("Enter more detail")
}
})