fn
useTextareaAutosize
v0.0.15testeddemoAuto-resizes a `<textarea>` to fit its content. Reacts to user input, programmatic content changes, and element resize. Reuses `useEventListener` for a passive, auto-cleaned `input` listener and `useResizeObserver` to re-measure when the textarea's width changes (so reflowed text is re-fitted). SSR safe.
Examples
ts
const { textarea, input } = useTextareaAutosize();
// <textarea ref="textarea" v-model="input" />ts
const { textarea, input, triggerResize } = useTextareaAutosize({ maxHeight: 320 });Demo
Loading demo…
Signature
ts
export function useTextareaAutosize(options: UseTextareaAutosizeOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseTextareaAutosizeOptions | Options |
Returns
UseTextareaAutosizeReturn`textarea`, `input`, and `triggerResize`