Components
Textarea
Use the textarea component to allow the users to enter a longer string of text information such as feedback.
- Status
- To be reviewed
Contents
Contents
HTML
<div class="tna-form-item">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="feedback">
Enter your feedback
</label>
</div>
<div class="tna-form-item__body">
<textarea id="feedback" class="tna-textarea" name="feedback" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5"></textarea>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
{{ tnaTextarea({
label: "Enter your feedback",
id: "feedback",
name: "feedback"
}) }}
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
{{ tnaTextarea({
"label": "Enter your feedback",
"id": "feedback",
"name": "feedback"
}) }}
Prefilled
Contents
HTML
<div class="tna-form-item">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="feedback">
Enter your feedback
</label>
</div>
<div class="tna-form-item__body">
<textarea id="feedback" class="tna-textarea" name="feedback" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5">I like this 👍🏼</textarea>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
{{ tnaTextarea({
label: "Enter your feedback",
id: "feedback",
name: "feedback",
value: "I like this 👍🏼"
}) }}
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
{{ tnaTextarea({
"label": "Enter your feedback",
"id": "feedback",
"name": "feedback",
"value": "I like this 👍🏼"
}) }}
Hint
Contents
HTML
<div class="tna-form-item">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="feedback">
Enter your feedback
</label>
</div>
<p id="feedback-hint" class="tna-form-item__hint">
Tell us what you think about this service.
</p>
<div class="tna-form-item__body">
<textarea id="feedback" class="tna-textarea" name="feedback" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5" aria-describedby="feedback-hint "></textarea>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
{{ tnaTextarea({
label: "Enter your feedback",
id: "feedback",
name: "feedback",
hint: "Tell us what you think about this service."
}) }}
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
{{ tnaTextarea({
"label": "Enter your feedback",
"id": "feedback",
"name": "feedback",
"hint": "Tell us what you think about this service."
}) }}
Error
Contents
HTML
<div class="tna-form-item tna-form-item--error">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="feedback">
Enter your feedback
</label>
</div>
<p id="feedback-error" class="tna-form-item__error">
<span class="tna-visually-hidden">Error:</span> Enter some feedback
</p>
<div class="tna-form-item__body">
<textarea id="feedback" class="tna-textarea" name="feedback" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5" aria-describedby=" feedback-error "></textarea>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
{{ tnaTextarea({
label: "Enter your feedback",
id: "feedback",
name: "feedback",
error: {
text: "Enter some feedback"
}
}) }}
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
{{ tnaTextarea({
"label": "Enter your feedback",
"id": "feedback",
"name": "feedback",
"error": {
"text": "Enter some feedback"
}
}) }}
Character count
You can set a soft limit on the number of characters (or words) allowed in a textarea.
Important information
Contents
HTML
<div class="tna-form-item" data-module="tna-textarea-character-count">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="feedback">
Enter your feedback
</label>
</div>
<div class="tna-form-item__body">
<textarea id="feedback" class="tna-textarea" name="feedback" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5" aria-describedby=" feedback-count" data-max-length="100"></textarea>
<div id="feedback-count" class="tna-visually-hidden">
You can enter up to 100 characters</div>
<p class="tna-textarea-count" aria-hidden="true">
You can enter up to 100 characters</p>
<div class="tna-textarea-count__screen-reader-status tna-visually-hidden" aria-live="polite">
You can enter up to 100 characters</div>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
{{ tnaTextarea({
label: "Enter your feedback",
id: "feedback",
name: "feedback",
characterCount: {
max: 100
}
}) }}
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
{{ tnaTextarea({
"label": "Enter your feedback",
"id": "feedback",
"name": "feedback",
"characterCount": {
"max": 100
}
}) }}
Count types
There are three types of counter:
-
length(default) -
The length is calculated using code points (raw characters). Using this counter type means that some multibyte characters such as emojis and certain non-Latin characters are counted as multiple characters.
Use when you have technical limitations on the length of text, such as stoaring the value in a database or sending it through an API.
-
characters -
The character count tries to use locale-sensitive text segmentation. This more closely aligns to the number of visual characters on screen.
Use when there is no technical limitation in your service or the limit far exceeds your desired length by a factor of at least 10 to account for multibyte characters.
-
words -
Like
characters, the number of words is counted using locale-sensitive text segmentation. Some older browsers that lack the necessary features will fall back to simply counting words as blocks of characters with spaces in between.Use when you want to try and limit the complexity of text input, for example keeping an enquiry simple by limiting it to 100 words.
| Example text | length |
characters |
words |
words (older browser) |
|---|---|---|---|---|
text |
4 |
4 |
1 |
1 |
♥ |
1 |
1 |
0 |
1 |
❤️ |
2 |
1 |
0 |
1 |
🤦🏼♂️ |
7 |
1 |
0 |
1 |
cafȩ́ |
6 |
4 |
1 |
1 |
TheNationalArchives |
19 |
19 |
1 |
1 |
The_National💪🏼Archives |
24 |
21 |
2 |
1 |
Contents
HTML
<div class="tna-container">
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
<div class="tna-form-item" data-module="tna-textarea-character-count">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="input1">
Enter text (length)
</label>
</div>
<div class="tna-form-item__body">
<textarea id="input1" class="tna-textarea" name="input1" spellcheck="false" autocapitalize="off" autocorrect="off" rows="2" aria-describedby=" input1-count" data-max-length="100" data-debounce-duration="100">I ❤️ design</textarea>
<div id="input1-count" class="tna-visually-hidden">
You can enter up to 100 characters</div>
<p class="tna-textarea-count" aria-hidden="true">
You can enter up to 100 characters</p>
<div class="tna-textarea-count__screen-reader-status tna-visually-hidden" aria-live="polite">
You can enter up to 100 characters</div>
</div>
</div>
</div>
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
<div class="tna-form-item" data-module="tna-textarea-character-count">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="input2">
Enter text (characters)
</label>
</div>
<div class="tna-form-item__body">
<textarea id="input2" class="tna-textarea" name="input2" spellcheck="false" autocapitalize="off" autocorrect="off" rows="2" aria-describedby=" input2-count" data-max-length="100" data-count-type="characters" data-debounce-duration="100">I ❤️ design</textarea>
<div id="input2-count" class="tna-visually-hidden">
You can enter up to 100 characters</div>
<p class="tna-textarea-count" aria-hidden="true">
You can enter up to 100 characters</p>
<div class="tna-textarea-count__screen-reader-status tna-visually-hidden" aria-live="polite">
You can enter up to 100 characters</div>
</div>
</div>
</div>
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
<div class="tna-form-item" data-module="tna-textarea-character-count">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="input3">
Enter text (words)
</label>
</div>
<div class="tna-form-item__body">
<textarea id="input3" class="tna-textarea" name="input3" spellcheck="false" autocapitalize="off" autocorrect="off" rows="2" aria-describedby=" input3-count" data-max-length="10" data-count-type="words" data-debounce-duration="100">I ❤️ design</textarea>
<div id="input3-count" class="tna-visually-hidden">
You can enter up to 10 words</div>
<p class="tna-textarea-count" aria-hidden="true">
You can enter up to 10 words</p>
<div class="tna-textarea-count__screen-reader-status tna-visually-hidden" aria-live="polite">
You can enter up to 10 words</div>
</div>
</div>
</div>
</div>
<script>
const inputs = [
document.getElementById("input1"),
document.getElementById("input2"),
document.getElementById("input3")
];
const update = (event) => {
inputs
.filter(input => input !== event.target)
.forEach(input => {
input.value = event.target.value;
input.dispatchEvent(new Event("focus"));
})
}
inputs.forEach(input => {
input.addEventListener("input", update);
});
</script>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
<div class="tna-container">
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
{{ tnaTextarea({
label: "Enter text (length)",
id: "input1",
name: "input1",
value: "I ❤️ design",
rows: 2,
characterCount: {
max: 100,
debounceDuration: 100
}
}) }}
</div>
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
{{ tnaTextarea({
label: "Enter text (characters)",
id: "input2",
name: "input2",
value: "I ❤️ design",
rows: 2,
characterCount: {
max: 100,
countType : "characters",
debounceDuration: 100
}
}) }}
</div>
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
{{ tnaTextarea({
label: "Enter text (words)",
id: "input3",
name: "input3",
value: "I ❤️ design",
rows: 2,
characterCount: {
max: 10,
countType : "words",
debounceDuration: 100
}
}) }}
</div>
</div>
<script>
const inputs = [
document.getElementById("input1"),
document.getElementById("input2"),
document.getElementById("input3")
];
const update = (event) => {
inputs
.filter(input => input !== event.target)
.forEach(input => {
input.value = event.target.value;
input.dispatchEvent(new Event("focus"));
})
}
inputs.forEach(input => {
input.addEventListener("input", update);
});
</script>
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
<div class="tna-container">
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
{{ tnaTextarea({
"label": "Enter text (length)",
"id": "input1",
"name": "input1",
"value": "I ❤️ design",
"rows": 2,
"characterCount": {
"max": 100,
"debounceDuration": 100
}
}) }}
</div>
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
{{ tnaTextarea({
"label": "Enter text (characters)",
"id": "input2",
"name": "input2",
"value": "I ❤️ design",
"rows": 2,
"characterCount": {
"max": 100,
countType : "characters",
"debounceDuration": 100
}
}) }}
</div>
<div class="tna-column tna-column--width-1-3 tna-column--full-small tna-column--full-tiny tna-!--margin-vertical-m">
{{ tnaTextarea({
"label": "Enter text (words)",
"id": "input3",
"name": "input3",
"value": "I ❤️ design",
"rows": 2,
"characterCount": {
"max": 10,
countType : "words",
"debounceDuration": 100
}
}) }}
</div>
</div>
<script>
const inputs = [
document.getElementById("input1"),
document.getElementById("input2"),
document.getElementById("input3")
];
const update = (event) => {
inputs
.filter(input => input !== event.target)
.forEach(input => {
input.value = event.target.value;
input.dispatchEvent(new Event("focus"));
})
}
inputs.forEach(input => {
input.addEventListener("input", update);
});
</script>
Considerations for counters
Keep in mind:
- this feature relies on JavaScript
- there is no way for this component to stop a user posting more than the maximum number of characters - you also need to validate their input in the backend of your service
- line breaks can sometimes be either one or two characters depending on your backend service's operating system
- users will be easily able to circumvent word count limits by using no spaces so you might need to also implement a length restriction in your application
- where possible, ensure your service calculates the length using a similar method to the frontend to avoid validation disagreements between the front and back ends
Itemised
Important information
Allow users to enter a number of values into a field with the itemised textarea. This component does not feature autocomplete.
Without JavaScript, this renders a normal <textarea> where values can be separated by line breaks.
Contents
HTML
<div class="tna-form-item">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="series-no-js">
Search series (without JavaScript)
</label>
</div>
<p id="series-no-js-hint" class="tna-form-item__hint">
Enter each series on a separate line
</p>
<div class="tna-form-item__body">
<textarea id="series-no-js" class="tna-textarea" name="series-no-js" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5" aria-describedby="series-no-js-hint "> Series 1
Series 2
Series 3 </textarea>
</div>
</div>
<div class="tna-form-item" data-module="tna-textarea-itemised-rows" data-enhanced-hint="Enter a series and press enter">
<div class="tna-form-item__header">
<label class="tna-form-item__label tna-heading-m" for="series">
Search series (with JavaScript)
</label>
</div>
<p id="series-hint" class="tna-form-item__hint">
Enter each series on a separate line
</p>
<div class="tna-form-item__body">
<textarea id="series" class="tna-textarea" name="series" spellcheck="false" autocapitalize="off" autocorrect="off" rows="5" aria-describedby="series-hint "> Series 1
Series 2
Series 3 </textarea>
</div>
</div>
Nunjucks
Nunjucks options
| Name | Type | Description |
|---|---|---|
| label | string |
Required. The label for the textarea field. |
| headingLevel | number |
The heading level which represents an element from |
| headingSize | string |
The physical size of the textarea title ( Default value: |
| id | string |
Required. A unique ID for the textarea component. |
| name | string |
Required. The name of the form field. |
| hint | string |
An optional hint to display above the form field. |
| value | string |
The form field value. |
| error | object |
If set, the details of any errors. |
| characterCount | object |
Configuration for the character count feature. Can not be used with |
| spellcheck | boolean |
If Default value: |
| autocapitalize | string |
If Default value: |
| autocorrect | boolean |
If Default value: |
| size | string |
Set the width of the textarea. Can be |
| rows | number |
Set the number of visible text lines for the textarea. A scrollbar will appear if the content exceeds the height. Default value: |
| itemiseRows | boolean |
If Default value: |
| formItemClasses | string |
Classes to add to the textarea form group. |
| formItemAttributes | object |
HTML attributes (for example data attributes) to add to the textarea form group. |
| classes | string |
Classes to add to the textarea. |
| attributes | object |
HTML attributes (for example data attributes) to add to the textarea. |
| Name | Type | Description |
|---|---|---|
| text | string |
Required. The error text to display. |
| Name | Type | Description |
|---|---|---|
| max | number |
Required. The maximum number of characters (or words if countType is set to |
| countType | string |
The type of character count to display. Can be Default value: |
| threshold | number |
The character count threshold in percent at which to start displaying a warning. Default value: |
| debounceDuration | number |
The debounce duration in milliseconds for updating the character count. Default value: |
{% from "nationalarchives/components/textarea/macro.njk" import tnaTextarea %}
{{ tnaTextarea({
label: "Search series (without JavaScript)",
hint: "Enter each series on a separate line",
id: "series-no-js",
name: "series-no-js",
value: " Series 1\n \nSeries 2 \n Series 3 "
}) }}
{{ tnaTextarea({
label: "Search series (with JavaScript)",
hint: "Enter each series on a separate line",
id: "series",
name: "series",
value: " Series 1\n \nSeries 2 \n Series 3 ",
itemiseRows: true,
formItemAttributes: {
"data-enhanced-hint": "Enter a series and press enter"
}
}) }}
Jinja
Important information
{% from "components/textarea/macro.html" import tnaTextarea %}
{{ tnaTextarea({
"label": "Search series (without JavaScript)",
"hint": "Enter each series on a separate line",
"id": "series-no-js",
"name": "series-no-js",
"value": " Series 1\n \nSeries 2 \n Series 3 "
}) }}
{{ tnaTextarea({
"label": "Search series (with JavaScript)",
"hint": "Enter each series on a separate line",
"id": "series",
"name": "series",
"value": " Series 1\n \nSeries 2 \n Series 3 ",
"itemiseRows": True,
"formItemAttributes": {
"data-enhanced-hint": "Enter a series and press enter"
}
}) }}
Component status
- Tested without CSS
- Yes
- Passed DAC audit
- Not yet audied