Skip to main content
cngx-src documentation

CngxAutosize

DirectivePrimaryv0.1.0WCAG AA

projects/forms/input/autosize.directive.ts

Import#

import { CngxAutosize } from '@cngx/forms/input'

Description#

Auto-resize textarea based on content.

Signal-first alternative to cdkTextareaAutosize. Measures via the scrollHeight trick and reacts to input events + ResizeObserver for programmatic value changes.

<textarea cngxAutosize [minRows]="2" [maxRows]="10" #auto="cngxAutosize"></textarea>
<span>Height: {{ auto.height() }}px</span>

https://cngxjs.github.io/cngx/examples/#/forms/input/autosize/basic-autosize https://cngxjs.github.io/cngx/examples/#/forms/input/autosize/min-max-rows

Metadata#

Host#

Index#

Inputs#

maxRows#number | undefined
input()

Maximum number of rows. undefined = unlimited.

minRows#number
input()

Minimum number of rows.

default 1

Instance Properties#

height#Signal
Readonly

Current computed height in px.

this.heightState.asReadonly()

Methods#

resize#void

Force recalculation of the textarea height.

HostBindings#

BindingExpression
[style.overflow-y]overflowY()
[style.resize]"none"
[style.box-sizing]"border-box"

HostListeners#

EventHandler
(input)input()