Reference
Textarea
Several lines of text. With label, hint or error it is a labelled field; with maxLength it counts what is left.
Textarea(bind: State, label: String, hint: String, …)
Since 6.2.0
label
hint
placeholder
rows
maxLength
0 of 280 characters
Example
state feedback = ""
Textarea(bind: feedback, label: "What could we do better?", hint: "Be as specific as you like.", placeholder: "The export was slow when…", rows: 4, maxLength: 280)
Text("{feedback.length} of 280 characters").muted
Grows with its text
state note = ""
Textarea(bind: note, label: "Release notes", rows: 2).autosize
With an error message
state bio = ""
derived bioError = if bio.length < 20 { "Write at least 20 characters." } else { "" }
Textarea(bind: bio, label: "About you", error: bioError, rows: 3).required
Disabled
state terms = "These terms apply to every workspace."
Textarea(bind: terms, label: "Terms", rows: 3).disabled
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
bind: | State | The | |
label: | String | none | Visible label; also the control's accessible name |
hint: | String | none | Help text under the control, linked to it by |
error: | String | none | Error text (a string; empty when there is none): announced as it appears and sets |
placeholder: | String | none | Hint shown while the field is empty |
rows: | Number | 2 (the browser's), drawn at least 6rem tall | How many lines tall it is drawn; never less than 6rem |
maxLength: | Number | no limit | The most characters it takes; a count beneath it ( |
required: | Bool | false | Whether the browser refuses to submit the form while it is empty. Written as a flag, |
autosize: | Bool | false | Grows taller with its text, from |
disabled: | Bool | false | Whether the control is inert: it cannot be focused or changed, and a form does not send it. Written as a flag, |
Attribute families: global, aria, data, input. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
.required
.autosize
.disabled
Events
The DOM events it is drawn to answer. Any other DOM event works too, in an on … { } handler.
| Event | Sends | Meaning |
|---|---|---|
on input | DOM | The value changed, on every keystroke |
on change | DOM | The value was committed |
on keydown | DOM | A key went down; `e.key` names it |
on focus | DOM | The element received focus |
on blur | DOM | The element lost focus |
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-input wf-textarea, stable across releases, so a stylesheet may target it.