Textarea
When to use this component
Use the textarea component when you need to let users enter an amount of text that’s longer than a single line.
When not to use this component
Users can find open-ended questions difficult to answer. It might be better to break up one complex question into a series of simple ones, for example where users can select from options using radios.
If you need to ask an open question
Do not use the textarea component if you need to let users enter shorter answers no longer than a single line, such as a phone number or name. In this case, you should use the text input component.
How it works
You must label textareas. Placeholder text is not a suitable substitute for a label, as it disappears when users click inside the textarea.
Labels must be aligned above the textarea they refer to. They should be short, direct and written in sentence case. Do not use colons at the end of labels.
You can use the above HTML.
Use appropriately-sized textareas
Make the height of a textarea proportional to the amount of text you expect users to enter. You can set the height of a textarea by by specifying the rows attribute.
Do not disable copy and paste
Users will often need to copy and paste information into a textarea, so do not stop them from doing this.
If you’re asking more than one question on the page
If you’re asking more than one question on the page, do not set the contents of the <label>
as the page heading.
Limiting the number of characters
If there’s a good reason to limit the number of characters users can enter, you can use the character count component.
Error message
Error messages should be styled like this:
Make sure errors follow the guidance in error message and have specific error messages for specific error states.
If the input is empty
Say Εισάγετε [ό,τι είναι]’. For example, ‘Εισάγετε περιεχόμενο’.
If the input is too long
Say ‘[ό,τι είναι] πρέπει να είναι [αριθμός] χαρακτήρες ή λιγότερο’. For example, ‘Η περιγραφή πρέπει να είναι 400 χαρακτήρες ή λιγότερο’.
If the input is too short
Say ‘[ό,τι είναι] πρέπει να είναι [αριθμός] χαρακτήρες ή περισσότερο’. For example, ‘Η περιγραφή πρέπει να είναι 10 χαρακτήρες ή περισσότερο’.
If the input is too long or too short
Say ‘[ό,τι είναι] πρέπει να είναι από [αριθμός] μέχρι [αριθμός] χαρακτήρες. For example, ‘Η περιγραφή πρέπει να είναι από 10 μέχρι 400 χαρακτήρες.
If the input uses characters that are not allowed and you know what the characters are
Say ‘[ό,τι είναι] δεν πρέπει να περιλαμβάνει [χαρακτήρες]’. For example, ‘Η περιγραφή δεν πρέπει να περιλαμβάνει è ή £’.
If the input uses characters that are not allowed and you do not know what the characters are
Say ‘[ό,τι είναι] πρέπει μόνο να περιλαμβάνει [λίστα από επιτρεπόμενους χαρακτήρες]’. For example, ‘Η περιγραφή πρέπει μόνο να περιλαμβάνει τα γράμματα α μέχρι ω, παύλες, κενά και απόστροφους.