ba-input-textarea
The textarea component provides a form control for long-form text input
Airframe
Web Components
React
React Native
Anatomy
Label
A short, descriptive text that identifies the purpose of the textarea field
Hint text (optional)
Additional guidance below the label to help users complete the field correctly
Textarea field
The multi-line text entry area where users type their response, which can grow in height when the auto-grow attribute is set
Design Documentation
For use when the user is required to input large amounts of text.
If only a small amount of text is needed such as a name, use <ba-input-text>
When setting a maxlength attribute, consider that many languages require more characters to express the same meaning. Ensure that the maximum length accommodates translations. For a guideline on the expected character length for different languages, refer to the multilingual design guidelines.
Live Demo
Custom error message
<ba-input-textarea
label="Please enter your message below"
hint-text="Help text for the field"
value=""
name="name"
auto-grow
>
<p slot="error">Custom error message</p>
</ba-input-textarea>
Properties and attributes
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
autoGrow |
auto-grow |
If true, the element height will increase based on the value. |
boolean | undefined |
false |
hintText |
hint-text |
Hint text to show above the input | string | undefined |
undefined |
inputWidth |
input-width |
The width of the input in characters | string | undefined |
undefined |
invalid |
invalid |
If true, the textarea's content is incorrect |
boolean | undefined |
false |
label(required) |
label |
A label for the input | string |
undefined |
maxlength |
maxlength |
This attribute specifies the maximum number of characters that the user can enter. Shows a character count when set. | string | undefined |
undefined |
minlength |
minlength |
This attribute specifies the minimum number of characters that the user can enter. | string | undefined |
undefined |
name(required) |
name |
The name of the control, which is submitted with the form data. | string |
undefined |
required |
required |
If true, the user must fill in a value before submitting a form. |
boolean | undefined |
false |
rows |
rows |
The number of visible text lines for the textarea. | number | undefined |
3 |
value |
value |
The value of the textarea. | null | string | undefined |
'' |
Permitted ARIA roles
- None
Slots
| Slot | Description | Permitted elements |
|---|---|---|
"error" |
Element will be rendered in the error slot | <p> |
Parent components
ba-input-textarea can be slotted into:
<ba‑grid><ba‑form‑group‑dropdown><ba‑form‑group><ba‑form><ba‑flex><ba‑details><ba‑card‑segmented><ba‑card><ba‑accordion>
Events
| Event | Description | Type |
|---|---|---|
baBlur |
Emitted when the input loses focus. | CustomEvent<void> |
baFocus |
Emitted when the input has focus. | CustomEvent<void> |
baOnInput |
Emitted when a keyboard input occurred. | CustomEvent<KeyboardEvent> |
baSubmit |
Emitted when the user submits the form from within the component | CustomEvent<void> |
Methods
| Method | Description |
|---|---|
isValid() => Promise<boolean> |
Triggers required validation and resolves with validity state. |
reset() => Promise<void> |
Resets the textarea back to its initial value and validity. |
Usage
Basic usage
A simple textarea input.
<ba-input-textarea label="Label text" name="textarea" required></ba-input-textarea>
Help text
It is sometimes useful to add hint text.
<ba-input-textarea label="Label text" name="textarea" hint-text="Custom hint text" required></ba-input-textarea>
Error messages
It is sometimes useful to add custom validation messages. For example you may wish to:
- Add translations
- Provide more detail and/or contextual advice
- Add links to further information on the error
We do provide error messages with translations for:
- required
- minlength error
- maxlength error
<ba-input-textarea label="Label text" name="textarea" hint-text="Custom hint text" required>
<p slot="error">
We need to know this. <a href="#">Why we need to know</a>
</p>
</ba-input-textarea>
Guidelines
The component allows users to type or paste text that exceeds the defined maxlength. This ensures users who have difficulty tracking character counts can still complete their input, review it in full, and make edits before submission
When a user focuses on the textarea, assistive technologies announce the maximum character limit if a maxlength attribute is present. This ensures users relying on screen readers understand input constraints before typing begins.
This behavior addresses a common screen reader quirk: live character counters (using aria-live) are not always announced when focus first enters the textarea. By providing the limit as part of an accessible description, announced on focus, we ensure all users receive the same contextual information.
Always use the label attribute to give a meaningful label to the field.
Further reading:
Disabled form elements are not supported in BAgel because they create accessibility challenges, such as preventing keyboard navigation, confusing screen reader users, and reducing visual clarity for those with impairments
Further reading:
Placeholders on inputs are not supported in BAgel because they create accessibility challenges, such as failing to provide persistent labels for screen readers, reducing color contrast for users with visual impairments, and causing confusion for those with cognitive difficulties.
If you would like to add a infomations to help the user fill the input, you can use the hint-text attribute.
Further reading:
Keyboard navigation
State: Previous element in DOM has focus
Moves focus to the ba-input-textarea field
State: ba-input-textarea field has focus
Moves focus to the next focusable element
Moves focus to the previous focusable element
Inserts a new line within the textarea
Usage and accessibility checklist
Use this checklist to confirm the component has been configured and used correctly.
UX checklist
- ba-input-textarea is only used when users need to enter more than one line of text
- ba-input-text is used instead when only a small amount of text is required, such as a name
- A concise and descriptive label has been provided
- Hint text is used when the expected format or constraints may not be obvious to the user
- Required fields are marked with the required attribute
- minlength and maxlength are set where the input has known character constraints, with translations accounted for
- auto-grow is considered where the amount of content is unpredictable, so users are not restricted to a fixed, scrollable box
Accessibility checklist
- A meaningful label is provided via the label attribute
- Hint text is used in preference to placeholder text, which is not supported
- Error messages are descriptive and explain how to resolve the validation failure
- The disabled state is not used — ba-input-textarea does not support disabled inputs
These checks are handled by the component and do not need to be repeated each time it is used.
- The field is keyboard operable and receives a visible focus indicator
- Colour contrast meets WCAG AA for text and border in all states (default, focus, error)
- The component renders correctly in Windows High Contrast Mode
- Animation and transitions respect the prefers-reduced-motion media query
- The maxlength limit is announced on focus so screen reader users understand input constraints before typing begins