GC Design SystemComponents
GC Design System Start to use Page templates overviewBasic page Components overviewAlertBreadcrumbsButtonCardCheckboxesContainerDate inputDate modifiedDetailsError messageError summaryFieldsetFile uploaderFooterGridHeaderHeadingIconInputLanguage toggleLinkNoticePaginationRadiosScreenreader-onlySearchSelectSide navigationSignatureStepperTableTextTextareaTheme and topic menuTop navigation CSS Shortcuts overview Reset styles Responsive layoutState Box sizingContainer sizingDisplayOverflowPositionVisibility FontFont familyFont sizeFont styleFont weightLine heightLink colourLink sizeLink text decorationList styleText alignText colourText overflowText transformWord break MarginPadding Align contentAlign itemsAlign selfFlexFlex directionFlex growFlex shrinkFlex wrapGapGrid columnsGrid rowsJustify contentJustify itemsJustify selfOrderPlace contentPlace itemsPlace self Background colourBorder colourBorder radiusBorder styleBorder width Icon namesIcon sizeImage CursorPointer eventsTransition Styles overviewDesign tokensColourSpacingTypography Contact usGet InvolvedFind a demo

Textarea
<gcds-textarea>

Also called: text box. A textarea is a space to enter long-form information in response to a question or instruction.

Textarea component preview

On this page

Coding and accessibility for textareas

Apply required attributes

Always use the following required attributes with gcds-textarea:
  • name
  • label
  • textarea-id

Size the field to fit the response

  • Use the rows attribute to set the height of a textarea to match the amount of text you expect someone to enter.
  • Use input for responses that need less than 75 characters.
  • Avoid setting the width lower than 50%.
  • Use the maximum height of 7 rows for responses without a fixed length.
Add hint text
  • Use the hint attribute to add hint text.
  • Avoid adding hint text in the field where it will disappear once the field is selected or a response starts to be entered.

Add character limits

  • Use the max-length attribute to enable character limits. This automatically adds “Characters left:” text below the textarea field.
  • Use the hide-limit attribute to visually hide the text.
Hide the label
  • Set the hide-label attribute to true to visually hide the label while maintaining it for assistive technologies.
  • Avoid adding hint text when the label is hidden.
Add validation and error messages
  • Use the required attribute to activate the built-in error messages and validation for textarea.
  • Fields with specific input requirements will validate if the entry is invalid, even if it is not required.
  • For optional fields that need validation, like email address formats, add custom validation with a custom error message.

Examples

Explore the different ways you can configure the component. Each example shows a working implementation and ready-to-copy code.

In this section

Essential attributes

These attributes are needed for the component to function correctly.

label

The label attribute defines the label for the textarea.
<gcds-textarea
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

name

The name attribute identifies the textarea component within a form. It is used to reference the textarea’s value when a form is submitted.
<gcds-textarea
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

textarea-id

The textarea-id attribute specifies the unique identifier for the textarea.
<gcds-textarea
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

Optional attributes

These attributes allow you to customize or extend the component’s behaviour and presentation.

autofocus

The autofocus attribute controls whether the textarea will be focused automatically when the page loads. By default, it is set to false. When set to true, the textarea is focused on render.
<gcds-textarea
  autofocus="true"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

cols

The cols attribute defines the visible width of the textarea in average character widths. The minimum width is 50% of its container.
<gcds-textarea
  cols="8"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

disabled

The disabled attribute controls whether the textarea is disabled or not. By default, it is set to false.
<gcds-textarea
  disabled="true"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

error-message

The error-message attribute defines the error message to display for an invalid textarea.
<gcds-textarea
  error-message="Error message"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

form

The form attribute specifies the ID of the form that the textarea belongs to.
<gcds-textarea
  form="form-id"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

hide-label

The hide-label attribute controls whether the label is hidden or not.
<gcds-textarea
  hide-label="true"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

hide-limit

The hide-limit attribute controls whether the character limit counter is displayed or not. When set to true, the character limit counter is not displayed. By default, it is set to false.
<gcds-textarea
  hide-limit="true"
  maxlength="20"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

hint

The hint attribute defines the hint text displayed under the label.
<gcds-textarea
  hint="Hint / Example message."
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

maxlength

The maxlength attribute defines the maximum number of characters that the textarea field can accept.
<gcds-textarea
  maxlength="10"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

minlength

The minlength attribute defines the minimum number of characters that the textarea field can accept.
<gcds-textarea
  minlength="5"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

required

The required attribute controls whether the textarea field is required or not. When set to true, it adds “required” after the label, and activates the required validator.
<gcds-textarea
  required="true"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

rows

The rows attribute defines the number of visible text rows in the textarea, which determines its height.
<gcds-textarea
  rows="3"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

validate-on

The validate-on attribute defines the validation event for the textarea.
<gcds-textarea
  validate-on="other"
  required="true"
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>

value

The value attribute sets the initial content of the textarea. It updates to reflect the value entered by the user.
<gcds-textarea
  value="Textarea content."
  textarea-id="textarea-example"
  label="Label"
  name="textarea-example"
></gcds-textarea>
Code builder Generate an instance of the component you need by selecting its code properties.
  • Explore by choosing different code values to generate the instance you want.
  • Get the code and pull it into your environment.
  • Add any copy you need to the component (like text for a label).
Note: The code builder uses English for all code elements, which follows standard practice.
Help us improve Have questions or a request? Give feedback on our contact form. Something's wrong? Raise it through GitHub with an account. You'll have access to the team's direct responses, progress made on your issue, and issues raised by others. Give feedback Report an issue on GitHub
2026-09-09