Skip to main content

A multi-line text input that works with Field, with optional word count, screen reader announcements, and submit-on-Enter.

<primitives:textarea.root>
    <primitives:textarea.label />
    <primitives:textarea.textarea />
    <primitives:textarea.wordCount />
</primitives:textarea.root>
typo3 ui:add textarea

Read more about installing Components and Primitives.

Nest ui:textarea.root directly inside ui:field.root - it inherits name, disabled, required, invalid and aria-describedby automatically, the same way ui:input/ui:select do. Use the primitive's own label part (nested inside root) rather than field.label - it targets the right control automatically.

Shown on your public profile.

Pass maxLength and add the wordCount part wherever you want it - it doesn't need to be a direct sibling of textarea.

0 / 280 characters

Pass submitOn="{f:constant(name: 'Jramke\FluidPrimitives\Enum\TextareaSubmitOn::ModEnter')}" to submit the nearest <form> on Cmd/Ctrl+Enter instead of inserting a newline - plain Enter still inserts a newline. Use TextareaSubmitOn::Enter for the opposite: plain Enter submits, Shift+Enter inserts a newline. Wrap the textarea in ui:form.root (or any native <form>) for the submit to actually go anywhere - submitOn just calls closest('form')?.requestSubmit().

transform runs on every native input event, before the value is committed - return the value that should actually be written back to the textarea, with cursor position preserved across the rewrite. Because a real function can't cross the PHP → client JSON boundary, this can only be set by constructing Textarea yourself in a custom entry file, rather than as a Fluid prop. Type lowercase below - it's uppercased as you type:

The following tables cover the available props of the Fluid Primitives.

Provides shared textarea state and wraps all related parts. Renders a <div> element.

NameDescriptionRequiredDefault
placeholderstring
Placeholder text shown when the textarea is empty.
No
-
autocompletestring
Hints for browser autofill, e.g. street-address. See the [HTML spec](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill) for the full list of tokens.
No
-
namestring
The name attribute of the textarea. Useful for form submission. Inherited from a surrounding field when available.
No
-
disabledboolean
Whether the textarea is disabled. Inherited from a surrounding field when available.
No
-
invalidboolean
Whether the textarea value is invalid. Inherited from a surrounding field when available.
No
-
requiredboolean
Whether the textarea is required. Inherited from a surrounding field when available.
No
-
readOnlyboolean
Whether the textarea is readonly. Inherited from a surrounding field when available.
No
-
defaultValuestring
The initial value of the textarea when rendered. Use when you don't need to control the value of the textarea. Inherited from a surrounding field when available.
No
''
maxLengthinteger
The maximum number of characters allowed. Also drives the wordCount part, e.g. '42 / 250 characters'.
No
-
rowsinteger
The number of visible text lines.
No
-
submitOnEnum\TextareaSubmitOn
Submits the nearest form on a keypress instead of inserting a newline: Enter submits on plain Enter (Shift+Enter still inserts a newline), ModEnter submits on Cmd/Ctrl+Enter (plain Enter always inserts a newline). Unset (the default) never intercepts Enter.
No
-
translationsarray
Specifies the localized word count string. Use `f:translate` for per-template localization overrides when needed.
No
-
announceboolean
Whether the word count is announced to assistive tech as the user types. Set to false to stay silent.
No
true
announceDebounceinteger
Milliseconds to debounce word count announcements by, so rapid typing doesn't spam assistive tech. Set to 0 to announce every change immediately.
No
600
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-invalidPresent when invalid
data-disabledPresent when disabled
data-readonlyPresent when read-only

Labels the textarea. Renders a <label> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-invalidPresent when invalid
data-disabledPresent when disabled
data-requiredPresent when required

The editable textarea. Renders a <textarea> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-invalidPresent when invalid
data-disabledPresent when disabled
data-readonlyPresent when read-only

Displays the character count, e.g. '42 / 250 characters'. Renders a <span> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
NameDescriptionDefault
idstring
The unique identifier of the textarea.
-
idsRecord<string, string> | undefined
The ids of the parts other elements reference: textarea (the for of its label) and wordCount.
-
namestring | undefined
The name of the textarea, as it is submitted with the form. Taken from the closest field.
-
disabledboolean | undefined
Whether the textarea is disabled. Taken from the closest field.
-
readOnlyboolean | undefined
Whether the textarea is read-only. Taken from the closest field.
-
requiredboolean | undefined
Whether the textarea is required. Taken from the closest field.
-
invalidboolean | undefined
Whether the textarea is invalid. Taken from the closest field.
-
defaultValuestring | undefined
The initial value of the textarea.
-
maxLengthnumber | undefined
The most characters allowed. It also drives the word count, e.g. 42 / 250 characters.
-
rowsnumber | undefined
The number of visible lines.
-
submitOnTextareaSubmitOn | undefined
Submits the closest <form> on a keypress instead of inserting a newline. 'enter' submits on Enter, Shift+Enter still inserts a newline. 'mod+enter' submits on Cmd or Ctrl+Enter, Enter always inserts a newline. By default Enter is never intercepted.
-
translationsTextareaTranslations | undefined
The localized texts of the textarea.
-
announceboolean | undefined
Whether the word count is announced to assistive tech. Set to false to stay silent.
true
announceDebouncenumber | undefined
Milliseconds to debounce word count announcements by, so rapid typing doesn't spam assistive tech on every keystroke. Set to 0 to announce every change immediately.
600
transform((value: string, event: Event) => string) | undefined
Runs on every native input event, before the value is committed. Return the value to write back to the textarea, e.g. trimmed. The cursor position is kept. It cannot be set from a Fluid template, only by constructing Textarea in your own entry file.
-
onValueChange((details: { value: string }) => void) | undefined
Called when the value changes.
-
NameTypeDescription
valuestringThe current value of the textarea.
countnumberThe number of characters in the value.
countTextstring | nullThe word count text, e.g. 42 / 250 characters. null without maxLength or when the text is turned off.
disabledbooleanWhether the textarea is disabled.
readOnlybooleanWhether the textarea is read-only.
requiredbooleanWhether the textarea is required.
invalidbooleanWhether the textarea is invalid.
namestring | undefinedThe name of the textarea.
maxLengthnumber | undefinedThe most characters allowed.