ComponentStandalone

Textarea

Multi-line text input with optional autosize. A signal-forms native control — it implements FormValueControl, so [formField] binds straight to its value model. [(value)] works standalone, and [(ngModel)] / reactive forms keep working through Angular 22's forms bridge.

Installation

import { WrTextarea } from 'ngwr/textarea';
import { FormsModule } from '@angular/forms';

@Component({ imports: [WrTextarea, FormsModule] })
export class MyComponent {}

Basic usage

<wr-textarea placeholder="Notes" [(value)]="text" />

Rows

<wr-textarea [rows]="5" />

Autosize

Grows with content. Combine with maxRows to cap height.

<wr-textarea autosize [maxRows]="6" [(value)]="text" />

Fixed size

<wr-textarea [resizable]="false" [(value)]="text" />

API

NameDescriptionTypeDefault
placeholderNative placeholder text.string''
ariaLabelAccessible name for the field. Falls back to the placeholder — the native <textarea> lives inside the component, so a <label for> outside cannot reach it.string | nullnull
sizeControl size — shares the --wr-control-* contract. Unset, it falls back to provideWrConfig({ textarea: { size } }).WrTextareaSize | null'md'
rowsVisible row count.number3
resizableAllow user resize via the corner grip.booleantrue
resizeResize direction of the corner grip (the grip icon adapts).WrTextareaResize'vertical'
readonlyRead-only state.booleanfalse
autosizeGrow the textarea to fit its content.booleanfalse
maxRowsCap autosize at this many rows. Ignored when autosize is false.number | nullnull
disabledDisable the textarea. Bound automatically from the field's disabled state when used with [formField].booleanfalse
valueThe edited text. Bound by [formField], or two-way via [(value)].string''
(touch)Emitted on blur so a bound field can mark itself touched.void

CSS variables

Custom properties ngwr/textarea publishes. Each default below is declared on the component's own selector, so a :root override is shadowed by it — set them on that selector, on a wrapper you scope yourself, or inline on the element. Unlike the BEM class names, these are the supported way to restyle the component.

VariableDefaultDeclared on
--wr-textarea-bgvar(--wr-color-surface).wr-textarea +1 variant override
--wr-textarea-bordervar(--wr-color-outline).wr-textarea +1 variant override
--wr-textarea-colorvar(--wr-color-on-surface).wr-textarea +1 variant override
--wr-textarea-font-sizevar(--wr-text-sm).wr-textarea +2 variant overrides
--wr-textarea-line-height1.375rem.wr-textarea +2 variant overrides
--wr-textarea-padding-xvar(--wr-control-padding-x-md).wr-textarea +2 variant overrides
--wr-textarea-padding-y0.5rem.wr-textarea +2 variant overrides
--wr-textarea-placeholderrgba(var(--wr-color-on-surface-muted-rgb), 0.7).wr-textarea
--wr-textarea-radiusvar(--wr-control-radius-md).wr-textarea +2 variant overrides
--wr-textarea-ringtransparent.wr-textarea +1 variant override