Textarea

A headless multi-line text input primitive with bindable value state and built-in agent support.

	<script lang="ts">
  import { Label, Textarea } from "bits-ui";
 
  let value = $state("");
</script>
 
<div class="flex w-full max-w-[340px] flex-col gap-1.5">
  <Label.Root
    for="release-notes-demo"
    class="text-sm font-medium text-foreground"
  >
    Release notes
  </Label.Root>
  <Textarea.Root
    id="release-notes-demo"
    bind:value
    rows={3}
    placeholder="Summarize what shipped in this release..."
    class="w-full resize-none rounded-card-sm border border-border-input bg-background px-3.5 py-2.5 text-sm text-foreground placeholder:text-foreground-alt/50 focus:border-foreground focus:outline-hidden data-filled:border-dark-40"
  />
</div>

Structure

	<script lang="ts">
  import { Textarea } from "bits-ui";
</script>
 
<Textarea.Root />

Managing Value State

Two-Way Binding

Use bind:value for automatic state synchronization:

	<script lang="ts">
  import { Textarea } from "bits-ui";
 
  let notes = $state("");
</script>
 
<Textarea.Root bind:value={notes} rows={4} placeholder="Write release notes..." />

Callback

Use onValueChange to react whenever the value updates from user input or an agent action:

	<Textarea.Root value={notes} onValueChange={(next) => (notes = next)} />

API Reference

Textarea.Root

A headless multi-line textarea primitive with bindable value state, styling data attributes, and automatic agent registration.

Property Details
value
onValueChange
disabled
readonly
required
ref
child
Data Attribute Details
data-textarea-root
data-disabled
data-readonly
data-required
data-filled

Agent Support

Registers as a multi-line text field that updates bind:value and dispatches bubbling native input and change events.

Action Description
setValue(value: string)

Updates bind:value and the DOM <textarea>, dispatching bubbling input and change events.

clear()

Clears the textarea to "" and dispatches bubbling input and change events.

State Description
component: "textarea"

Component kind returned in snapshot().

value: string

Current text content (or "[redacted]" when marked with data-agent-secret).

placeholder: string

Present when placeholder is set.

required: true

Present when required is true.

await agent.act({
	steps: [{ ref: "Release notes", action: "setValue", args: ["Added WebMCP support"] }],
});