Textarea
Multi-line text area with configurable rows, resize behavior, an auto-resize mode that grows with content, and the same four visual variants as TextInput.
import { Textarea } from "phoundry-ui";Basic
Loading interactive example…
View source
<script lang="ts"> import { Textarea } from "phoundry-ui";
let basic = $state("");</script>
<div class="max-w-md"> <Textarea value={basic} oninput={(v: string) => { basic = v; }} placeholder="Write something..." /></div><p class="mt-2 text-xs text-txt-tertiary">Length: {basic.length}</p>Auto-resize
Loading interactive example…
View source
<script lang="ts"> import { Textarea } from "phoundry-ui";
let autoResize = $state( "Type here and watch the textarea grow as you add more lines...", );</script>
<div class="max-w-md"> <Textarea value={autoResize} oninput={(v: string) => { autoResize = v; }} resize="auto" rows={2} /></div>Sizes
Loading interactive example…
View source
<script lang="ts"> import { Textarea } from "phoundry-ui";
let small = $state("");
let medium = $state("");
let large = $state("");</script>
<div class="flex max-w-md flex-col gap-3"> <Textarea value={small} oninput={(v: string) => { small = v; }} placeholder="Small" size="sm" rows={2} /> <Textarea value={medium} oninput={(v: string) => { medium = v; }} placeholder="Medium" size="md" rows={2} /> <Textarea value={large} oninput={(v: string) => { large = v; }} placeholder="Large" size="lg" rows={2} /></div>Variants
Loading interactive example…
View source
<script lang="ts"> import { Textarea } from "phoundry-ui";
let fillDemo = $state("");
let ghostDemo = $state("");
let outlineDemo = $state("");
let trueGhostDemo = $state("");</script>
<div class="flex max-w-md flex-col gap-3"> <Textarea value={outlineDemo} oninput={(v: string) => (outlineDemo = v)} variant="outline" placeholder="outline" rows={2} /> <Textarea value={fillDemo} oninput={(v: string) => (fillDemo = v)} variant="fill" placeholder="fill" rows={2} /> <Textarea value={ghostDemo} oninput={(v: string) => (ghostDemo = v)} variant="ghost" placeholder="ghost" rows={2} /> <Textarea value={trueGhostDemo} oninput={(v: string) => (trueGhostDemo = v)} variant="trueGhost" placeholder="true ghost" rows={2} /></div>Resize none & disabled
Loading interactive example…
View source
<script lang="ts"> import { Textarea } from "phoundry-ui";
let noneResize = $state("");
let disabledTa = $state("Disabled body");</script>
<div class="flex max-w-md flex-col gap-3"> <Textarea value={noneResize} oninput={(v: string) => (noneResize = v)} resize="none" rows={4} placeholder="Fixed height - no manual resize" /> <Textarea value={disabledTa} oninput={(v: string) => (disabledTa = v)} disabled rows={3} /></div>API
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
value | string | '' | Current textarea value. |
onchange | (value: string) => void | — | Fires on blur after value changes |
oninput | (value: string) => void | — | Fires on every keystroke |
placeholder | string | — | Placeholder text |
rows | number | 3 | Initial visible rows |
resize | "none" | "vertical" | "auto" | 'vertical' | Resize behavior - 'auto' grows with content |
size | "sm" | "md" | "lg" | 'md' | Typography and padding selected in CSS (no fixed height) |
variant | TextFieldVariant | 'outline' | Visual style. trueGhost has no border, fill, or hover/focus chrome. |
disabled | boolean | false | Disables the textarea |
readonly | boolean | false | Makes the textarea read-only |
class | ClassValue | — | Additional CSS classes |
style | string | — | Inline styles on the component styling target described below. |
id | string | — | HTML id attribute |
name | string | — | HTML name attribute for forms |
elementbindable | HTMLTextAreaElement | — | Bindable reference to the underlying textarea element |
…rest: Forwarded native attributes (rows also exists as an explicit prop).
Usage tips
- Use
resize="auto"for comment boxes or chat inputs where height should match content. - Set
resize="none"when the textarea lives inside a fixed-height layout (e.g. a split pane). - Pair with
FormFieldto add a label, helper text, and character count. - The auto-resize mode recalculates on every input - for very long documents, prefer
resize="vertical". - Use
variant="trueGhost"for inline editing where the parent already supplies hover/focus treatment. It has no border, fill, or focus ring — provide your own affordance if the field stands alone.
Styling
.ph-textarea is the stable root identification hook. Variant chrome and size configuration use the shared .ph-text-field primitive; anatomy stays in scoped CSS; data-size always identifies the selected size. class, style, native attributes, attachments, and bind:element target the textarea. data-variant exposes outline, fill, ghost, or trueGhost; data-resize exposes none, vertical, or auto. The outline surface shadow uses --ph-input-shadow. Focus uses the same variant chrome as hover, without a blue or accent-colored focus ring. trueGhost stays chrome-free. The theming guide documents public theme parts; other part selectors and --_ph-* properties remain implementation details.
The shared .ph-text-field primitive in phoundry-ui/styles/components.css keeps variant chrome and size configuration aligned with NumberInput. All three fields use --ph-field-radius (0.5rem) and --ph-input-shadow for outline surfaces. Focus and hover share the same appearance; native blue focus rings are suppressed.
outline has a quiet translucent background, muted border, and input shadow. fill uses the stronger neutral control background with no visible border or shadow; the distinction remains on hover and focus.