Components
← All components

Textarea Autosize

stimeo--textarea-autosize

Grows a textarea to fit its content, clamped between minRows and maxRows.

The stimeo--textarea-autosize controller grows a textarea to fit its content. On connect and on every input it collapses the element (height:auto), reads scrollHeight, and sets an explicit pixel height clamped between minRows and maxRows (in line-height units). At the maxRows cap it switches to internal scrolling and sets the data-at-max-rows hook, and it exposes the approximate row count on the --stimeo-textarea-rows custom property. Height-only changes keep focus and caret. Behavior only — the height is written to the element's own inline style (never a CSS class); connect re-measures after a Turbo navigation, and the input listener is removed on disconnect. It dispatches stimeo--textarea-autosize:resize when the height changes.

running