Textarea
<afp-textarea>
A textarea component to input and edit multi-line text, useful for capturing longer user-provided content.
Examples #
Shape #
Use the shape attribute to change a text area's shape.
Sizes #
Use the size attribute to change a textarea's size.
Hint #
Use the hint attribute to provide additional guidance or context below the textarea.
Placeholder #
Use the placeholder attribute to display hint text inside the textarea before the user enters any content.
Rows #
Use the rows attribute to set the number of visible rows (height) of the textarea.
Resize #
Use the resize attribute to change the textarea's resizing behavior.
Prefix and Suffix #
Use the prefix slot to add prefix to the textarea field.
Use the suffix slot to add prefix to the textarea field.
Clearable #
Use the clearable attribute to show clear icon button.
Required #
Use the required attribute to mark the textarea as mandatory.
Disabled #
Use the disabled attribute to mark the textarea as disabled.
Invalid #
Use the invalid attribute to show that the textarea has an error.
Customization #
Use the clear-icon slot to provide a custom icon for the clear button.
Properties
Learn more about properties.
| Name | Description | Reflects | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
value
|
value of the textarea field.
Type
string
|
|
||||||||||
label
|
label of the textarea field.
Type
string
|
|
||||||||||
ariaLabel
arialabel
|
Aria label for the textarea.
This is used for accessibility purposes to provide a text alternative for screen readers.
Type
string
|
|
||||||||||
placeholder
|
placeholder for the textarea.
Type
string
|
|
||||||||||
name
|
name of the textarea, used when submitting form data.
Type
string
|
|||||||||||
tooltip
|
show label tooltip by hover.
Type
boolean
|
|
||||||||||
disabled
|
disabled property of the textarea component.
Type
boolean
Default
false |
|
||||||||||
invalid
|
The error message displayed when the textarea is invalid.
If set, the textarea is shown in an error state with this message.
Type
string
|
|||||||||||
hint
|
hint footer property of textarea.
Type
string
|
|
||||||||||
required
|
marks the textarea as required.
When true, the textarea must have a value before submission.
The textarea label will display an asterisk (*).
Type
boolean
Default
false |
|
||||||||||
readonly
|
marks the textarea as readonly.
Type
boolean
Default
false |
|||||||||||
indicator
|
an indicator showing the text area’s maximum character limit.
Type
boolean
Default
true |
|
||||||||||
hideLabel
hidelabel
|
hides the label visually
Type
boolean
|
|
||||||||||
autofocus
|
autofocus on textarea.
Type
boolean
Default
false |
|||||||||||
autocorrect
|
textarea’s automatic spelling correction.
Type
boolean
Default
false |
|||||||||||
autocomplete
|
list of autocomplete strings
Type
string
Default
'off' |
|||||||||||
max
|
maximum number of characters allowed in the textarea.
Type
number
|
|||||||||||
rows
|
number of visible rows in the textarea.
Type
number
Default
1 |
|
||||||||||
textareaTabIndex
textareatabindex
|
html tabIndex property of textarea
Type
number
|
|
||||||||||
clearable
|
enables the clear button.
Type
boolean
Default
false |
|
||||||||||
resize
|
textarea resize option.
Type
AfpResize
Default
AfpResize.BOTH |
|
||||||||||
shape
|
shape of the textarea
Type
AfpShape
Default
AfpShape.ROUNDED |
|
||||||||||
size
|
size of the textarea
Type
AfpSize
Default
AfpSize.MEDIUM |
|
Events
Learn more about events.
| Name | Return | Description |
|---|---|---|
afp-focus
|
void
|
Emitted when the textarea gains focus.
|
afp-blur
|
void
|
Emitted when the textarea loses focus.
|
afp-clear
|
void
|
Emitted when the textarea is cleared.
|
afp-select
|
string
|
afp-select - Emitted when part of textarea gets selected.
|
afp-value-changed
|
string
|
Emitted when the textarea's value changes.
|
Slots
Learn more about slots.
| Name | Description |
|---|---|
label
|
Slot for adding custom label content
|
textarea-prefix
|
Slot for adding content before the textarea field
|
textarea-suffix
|
Slot for adding content after the textarea field
|
clear-icon
|
Slot for the icon of the textarea clear button
|
indicator-prefix
|
Slot for adding content before the textarea indicator
|
indicator-suffix
|
Slot for adding content after the textarea indicator
|
Internationalization
Learn more about internationalization.
| Key | Description |
|---|---|
textarea.clear-button.aria-label
|
The aria-label of the textarea's clear button.
|
CSS Parts
Learn more about CSS Parts.
| Name | Description | Selector |
|---|---|---|
base
|
The outer wrapper of the component
|
::part(base)
|
textarea
|
The editable textarea element
|
::part(textarea)
|
label
|
The container for the textarea's label
|
::part(label)
|
label-base
|
The base part of the label
|
::part(label-base)
|
hint
|
The part for the hint message
|
::part(hint)
|
hint-base
|
The base container for the hint message
|
::part(hint-base)
|
invalid
|
The part for the invalid message
|
::part(invalid)
|
invalid-base
|
The base container for the invalid message
|
::part(invalid-base)
|
indicator
|
The counter indicator
|
::part(indicator)
|
field
|
The part for the textarea field
|
::part(field)
|
disabled
|
The part for the disabled state of the textarea
|
::part(disabled)
|
actions
|
The container for textarea's actions
|
::part(actions)
|
clear-icon
|
The part for the clear icon
|
::part(clear-icon)
|
clear-button
|
The part for the clear button
|
::part(clear-button)
|
footer
|
The footer container for hint, invalid or indicator
|
::part(footer)
|
footer-text
|
The container for hint and invalid
|
::part(footer-text)
|
CSS Custom Properties
| Name | Description | Default |
|---|---|---|
--afp-textarea-actions-icon-color
|
The color of the textarea action icons.
|
--afp-color-bright-50
|
--afp-textarea-indicator-disabled-opacity
|
The opacity of the indicator when disabled.
|
0.5
|
--afp-input-error-label-color
|
The color of the label in the invalid/error state.
|
--afp-color-error-500
|
--afp-input-error-border-color
|
The border color of the textarea field in the invalid/error state.
|
--afp-color-error-500
|
--afp-input-error-message-color
|
The color of the error message/indicator in the invalid/error state.
|
--afp-color-error-500
|
Dependencies
The component automatically brings in the listed items, including any nested dependencies that may exist.
| Component | CSS Part Prefix |
|---|---|
|
|
clear-icon
- The part for the clear icon
|
|
|
clear-button
- The part for the clear button
|
Importing
Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.
import '@afp-design-system/core/dist/components/textarea/textarea.js';