ComponentUpdated in v15

Textarea

A multi-line text field that can grow with its content.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrTextarea } from 'ngwr/textarea';

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

Basic usage

Bind the text with [(value)] or any Angular form.

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

Rows

rows sets the starting height.

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

Autosize

autosize grows the field with its text; maxRows caps it.

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

Fixed size

[resizable]="false" removes the resize handle.

<wr-textarea [resizable]="false" [rows]="4" placeholder="No resize handle" />

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.WrTextareaSize'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

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/textarea's own element.

VariableDefaultDeclared on
--wr-textarea-bgvar(--wr-color-surface).wr-textarea +2 variant overrides
--wr-textarea-bordervar(--wr-border-base).wr-textarea +1 variant override
--wr-textarea-colorvar(--wr-color-on-surface).wr-textarea +1 variant override
--wr-textarea-font-familyvar(--wr-font-family-base).wr-textarea
--wr-textarea-font-sizevar(--wr-text-sm).wr-textarea +2 variant overrides
--wr-textarea-line-heightvar(--wr-control-line-height-md).wr-textarea +2 variant overrides
--wr-textarea-padding-xvar(--wr-control-padding-x-md).wr-textarea +2 variant overrides
--wr-textarea-padding-yvar(--wr-space-sm).wr-textarea +2 variant overrides
--wr-textarea-placeholdervar(--wr-color-placeholder).wr-textarea
--wr-textarea-radiusvar(--wr-control-radius-md).wr-textarea +2 variant overrides
--wr-textarea-ringtransparent.wr-textarea +1 variant override

Dependencies

Built onForm
Used bySchema Form

See also