$npx @dinachi/cli@latest add textarea
This appears on your public profile.
placeholderrowsdisabledreadOnlybio-field.tsx
import { Textarea } from "@/components/ui/textarea"
export function BioField() {
return (
<div>
<label htmlFor="bio">Bio</label>
<Textarea
id="bio"
placeholder="A sentence or two about yourself"
rows={4}
/>
<p>This appears on your public profile.</p>
</div>
)
}Usage
import { Textarea } from "@/components/ui/textarea"
export function BioField() {
return (
<div>
<label htmlFor="bio">Bio</label>
<Textarea id="bio" placeholder="A sentence or two about yourself" />
</div>
)
}Examples
This appears on your public profile.
A labelled field with helper text.
import { Textarea } from '@/components/ui/textarea';
export function Example() {
return (
<div className="space-y-2 w-full max-w-md">
<label htmlFor="bio" className="text-sm font-medium text-foreground">Bio</label>
<Textarea
id="bio"
placeholder="A sentence or two about yourself"
rows={4}
/>
<p className="text-sm text-muted-foreground">
This appears on your public profile.
</p>
</div>
);
}0 / 180 characters
A length limit the reader sees as they approach it.
import { Textarea } from '@/components/ui/textarea';
import { useState } from 'react';
export function Example() {
const [value, setValue] = useState('');
const limit = 180;
return (
<div className="space-y-2 w-full max-w-md">
<label htmlFor="summary" className="text-sm font-medium text-foreground">Summary</label>
<Textarea
id="summary"
placeholder="What is this release about?"
rows={4}
maxLength={limit}
value={value}
onChange={(event) => setValue(event.target.value)}
aria-describedby="summary-count"
/>
<p id="summary-count" aria-live="polite" className="text-sm text-muted-foreground">
{value.length} / {limit} characters
</p>
</div>
);
}Disabled and read-only states.
import { Textarea } from '@/components/ui/textarea';
export function Example() {
return (
<div className="space-y-4 w-full max-w-md">
<div className="space-y-2">
<label htmlFor="disabled-note" className="text-sm font-medium text-foreground">Disabled</label>
<Textarea id="disabled-note" placeholder="Not accepting notes right now" disabled />
</div>
<div className="space-y-2">
<label htmlFor="readonly-note" className="text-sm font-medium text-foreground">Read-only</label>
<Textarea
id="readonly-note"
value="Submitted on 12 March. Edits are closed."
readOnly
/>
</div>
</div>
);
}A multi-line field with placeholder text.
import { Textarea } from '@/components/ui/textarea';
export function Example() {
return <Textarea placeholder="Tell us what happened" className="max-w-md" />;
}Notes
When to use it
- Answers of a sentence or more.
- For a short value, use Input.
API
valuestring
Controlled text.defaultValuestring
Starting text when uncontrolled.onValueChange
Runs on every edit, for people and agents. agent
(value, details) => voiddetails.cancel() refuses an agent's change.onChange(event) => void
The native change event. Fires for typing and agent edits.rowsnumber
Visible height in lines. A min-height of 80px still applies.placeholderstring
Shown while the field is empty.maxLengthnumber
The most characters it accepts.readOnly
Selectable but not editable. Refuses agents too.agent
boolean = falsedisabled
Blocks people and agents.agent
boolean = falseAgent
Inside an AgentProvider, it appears in agent.snapshot() as textarea.
Reads
labelThe <label> tied to it, or its aria-label.
valueThe current text.
disabledTrue when the field is disabled.
Actions
setValue("Final")Replaces the text.
clear()Empties the field.
An agent's edit runs through onValueChange first. isAgentChange(details) is true for it; details.cancel() refuses it and tells the agent. A disabled or readOnly textarea refuses on its own.
await agent.act({
steps: [{ ref: "Bio", action: "setValue", args: ["Designer in Lagos."] }],
})Accessibility
- A native
<textarea>, with the browser's semantics and editing keys. - Name it with
<label htmlFor>or aria-label; the agent reads the same name. - Point aria-describedby at helper text and character counts.