Textarea
A multi-line text field that can grow with its content. Form-associated.
A comment with a character count
Autosize, rows and read-only
Variants, sizes and states
API
For AI agents: this API as Markdown, or every component in llms-full.txt.
<ray-textarea> · RayTextarea
Also forwards placeholder, autocomplete, minlength, maxlength, spellcheck and wrap. Initial value: the value attribute or the element's text.
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | Current value. | |
rows | rows | number | 3 | Visible rows (minimum when autosize). |
autosize | autosize | boolean | Grows with the content. | |
maxRows | max-rows | number | With autosize: stop growing and scroll after this many rows. | |
name | name | string | Form field name. | |
label | label | string | Visible label. | |
description | description | string | Help text. | |
descriptionPosition | description-position reflects | above | below | above | The description before the control (help first) or after it, with the error (fields in a row stay aligned). |
error | error | string | Error text. | |
required | required | boolean | Required for form submission. | |
disabled | disabled | boolean | Not editable nor submitted. | |
readonly | readonly | boolean | Not editable, still submitted. | |
size | size reflects | xs | sm | md | lg | xl | sm | Font size. |
variant | variant reflects | default | filled | unstyled | default | Box style. |
highlight | — | function | Marks ranges of the text, painted behind it: called with the text on every change (typed or set), it returns { start, end, kind?, title? } offsets. kind "error" is red with a wavy underline; any other kind is styled with ::part(highlight-<kind>); title is the tooltip over the range. Ranges must not overlap. | |
complete | — | function | Inline suggestions: called as the user types (and on Ctrl+Space) with the text and the caret, it returns the part of the text a suggestion would replace and the suggestions ({ from, to, items }), or null for none. A list opens under that part (ArrowUp/Down, Enter or Tab to accept, Escape to close); the chosen item's value replaces from–to as an undoable edit, then ray-complete fires. The field becomes a combobox (aria-autocomplete, aria-expanded, aria-activedescendant). | |
suggestionsLabel | suggestions-label | string | Suggestions (text textarea.suggestions) | Accessible name of the suggestion list. |
| Attribute | Description |
|---|---|
placeholder | Placeholder text. |
autocomplete | Forwarded to the inner textarea. |
minlength | Minimum length. |
maxlength | Maximum length. |
wrap | soft or hard. |
| Event | Description |
|---|---|
ray-complete | A suggestion was accepted (the text already has it). |
ray-highlight-hover | The highlight range under the pointer changed: the range and the box of the line of it the pointer is on, or null on leaving a range. Anchor a ray-popover to rect (its anchor property) to show more than the title. |
input | On every edit. |
change | When an edit is committed. |
| Part | Description |
|---|---|
textarea | The inner <textarea>. |
wrapper | The box. |
suggestions | The suggestion list (a listbox in the top layer). |
suggestion | Each suggestion ([aria-selected] when active). |
suggestion-label | A suggestion's label (in the mono font). |
suggestion-detail | A suggestion's detail. |
suggestion-description | A suggestion's description, under its label (in the interface font). |
highlight | Each marked range (also highlight-<kind> for a range with a kind). |
text-layer | The layer behind the text that holds the marks. |
Texts
What it writes itself, in English; setStrings() translates them (Getting started: Languages).
| Key | English |
|---|---|
textarea.suggestions | Suggestions |