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

wf

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

wf

state note = "" Textarea(bind: note, label: "Release notes", rows: 2).autosize

With an error message

wf

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

wf

state terms = "These terms apply to every workspace." Textarea(bind: terms, label: "Terms", rows: 3).disabled

Props

Props of Textarea
PropTypeUnsetMeaning

bind:

State

The String state it reads and writes as you type

label:

String

none

Visible label; also the control's accessible name

hint:

String

none

Help text under the control, linked to it by aria-describedby

error:

String

none

Error text (a string; empty when there is none): announced as it appears and sets aria-invalid

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 (12 / 200) says how many are used, read politely

required:

Bool

false

Whether the browser refuses to submit the form while it is empty. Written as a flag, .required, or required: true.

autosize:

Bool

false

Grows taller with its text, from rows: up, rather than scrolling. Written as a flag, .autosize, or autosize: true.

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, .disabled, or disabled: true.

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.

DOM events Textarea answers
EventSendsMeaning
on inputDOMThe value changed, on every keystroke
on changeDOMThe value was committed
on keydownDOMA key went down; `e.key` names it
on focusDOMThe element received focus
on blurDOMThe 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.