### File

`packages/components/eui-textarea/auto-resize.directive.ts`

### Description

A directive that automatically adjusts the height of a textarea based on its content.

The AutoResizeDirective automatically adjusts the height of a textarea element as the user types, ensuring that all content is visible without requiring manual resizing or scrolling. It supports minimum and maximum row constraints and can be enabled/disabled dynamically.

Example :

    <textarea autoResize [minRows]="2" [maxRows]="5"></textarea>

### Implements

`OnInit` `AfterViewInit` `OnDestroy`

### Metadata

Selector | `textarea[autoResize]`

### Index

###### Methods
onInput Public resize
###### Inputs
autoResize maxRows minRows
###### HostListeners
input

### Constructor

`constructor()`

### Inputs

autoResize
Type : `boolean, BooleanInput`
Default value : `true, { transform: booleanAttribute }`
Controls whether the auto-resize functionality is enabled. When true, the textarea will automatically adjust its height based on content. When false, the textarea will behave normally.

maxRows
Type : `number, NumberInput`
Default value : `0, { transform: numberAttribute }`
Sets the maximum number of rows for the textarea. When set to a value greater than 0, the textarea will not grow beyond this number of rows and will show scrollbars if necessary. When set to 0, there is no maximum limit.

minRows
Type : `number, NumberInput`
Default value : `1, { transform: numberAttribute }`
Sets the minimum number of rows for the textarea. This value determines the initial height of the textarea.

### HostListeners

input
Event handler for input events on the textarea. Triggers the resize calculation when the content changes.

### Methods

onInput
`onInput()`
Decorators : `@HostListener('input')`
Event handler for input events on the textarea. Triggers the resize calculation when the content changes. Returns : `void`

Public resize
`resize()`
Calculates and sets the appropriate height for the textarea based on its content. This method creates a temporary clone of the textarea to measure the required height, taking into account minRows and maxRows constraints. The calculation process: Creates a hidden clone of the textarea Sets the clone's width to match the original Measures the required height based on content Applies maxRows constraint if specified Updates the original textarea's height Returns : `void`

# results matching ""

# No results matching ""