Forms
Textarea
Multi-line text field for messages and notes. It grows with its content and shares the look of Input.
import { Textarea } from '@statix/ui/textarea';Playground
<Textarea placeholder="Describe the problem" />Examples
With a label
<script lang="ts">
import { Label } from '@statix/ui/label';
import { Textarea } from '@statix/ui/textarea';
</script>
<div class="flex w-full max-w-md flex-col gap-2">
<Label for="textarea-message">Message</Label>
<Textarea
id="textarea-message"
placeholder="What happened, and since when? For example: the contact form on yoga-berger.de shows an error since this morning."
/>
</div>With a character count
Bind the value and show the count under the field when there is a limit.
Jonas reads this before he calls you back. 0/280
<script lang="ts">
import { Label } from '@statix/ui/label';
import { Textarea } from '@statix/ui/textarea';
const max = 280;
let value = $state('');
</script>
<div class="flex w-full max-w-md flex-col gap-2">
<Label for="textarea-note">Note for Jonas</Label>
<Textarea
id="textarea-note"
bind:value
maxlength={max}
aria-describedby="textarea-note-hint"
placeholder="Anything we should know before the call?"
/>
<div id="textarea-note-hint" class="flex justify-between text-small text-muted-foreground">
<span>Jonas reads this before he calls you back.</span>
<span class="tabular-nums">{value.length}/{max}</span>
</div>
</div>Invalid
aria-invalid turns the border red. Link the message with aria-describedby.
Tell us in a few words why you want to cancel.
<script lang="ts">
import { Label } from '@statix/ui/label';
import { Textarea } from '@statix/ui/textarea';
</script>
<div class="flex w-full max-w-md flex-col gap-2">
<Label for="textarea-reason">Reason for cancelling</Label>
<Textarea id="textarea-reason" aria-invalid="true" aria-describedby="textarea-reason-error" />
<p id="textarea-reason-error" class="text-small text-destructive">
Tell us in a few words why you want to cancel.
</p>
</div>Disabled
<script lang="ts">
import { Label } from '@statix/ui/label';
import { Textarea } from '@statix/ui/textarea';
</script>
<div class="flex w-full max-w-md flex-col gap-2">
<Label for="textarea-closed">Reply</Label>
<Textarea
id="textarea-closed"
disabled
value="This ticket is closed. Open a new one if the problem comes back."
/>
</div>Guidelines
Do
- Use a textarea when the answer needs more than one line, such as a support message.
- Show the limit before people hit it, not after.
Don't
- Don't use a textarea for values with a fixed format such as a phone number or a domain.
Accessibility
- Renders a native <textarea>. Label it with <Label for> or aria-label.
- field-sizing: content lets it grow while typing. Set rows or a min-h class to change the start height.
- aria-invalid="true" switches to the error style.
API reference
Textarea
renders<textarea> and accepts its attributes| Prop | Type | Default |
|---|---|---|
value bind | string The current text. | – |
ref bind | HTMLTextAreaElement | null The rendered element. | – |
class | ClassValue Merged with the default classes; yours win. | – |
| Data attribute | Meaning |
|---|---|
data-slot="textarea" | Present unless you pass another data-slot. |