Skip to content

useTextareaAutosize

Category
Export Size
869 B
Last Changed
4 months ago

Automatically update the height of a textarea depending on the content.

Demo

Type, the textarea will grow:

Usage

vue
<script setup lang="ts">
const { textarea, input } = useTextareaAutosize()
</script>

<template>
  <textarea
    ref="textarea"
    v-model="input"
    class="resize-none"
    placeholder="What's on your mind?"
  />
</template>
<script setup lang="ts">
const { textarea, input } = useTextareaAutosize()
</script>

<template>
  <textarea
    ref="textarea"
    v-model="input"
    class="resize-none"
    placeholder="What's on your mind?"
  />
</template>

Source

SourceDemoDocs

Contributors

Anthony Fu
leex
JD Solanki
Dominik Pschenitschni
Jelf
Enzo Innocenzi

Changelog

v10.2.0 on 6/16/2023
1b0ec - fix: autosize error when changing input asynchronously (#3118)
v10.0.0-beta.0 on 3/14/2023
a3e95 - feat: added styleTarget option to style other element (#2312)
v9.7.0 on 12/16/2022
ea497 - fix: reference
ebd48 - fix: support changes of element width (#2541)
v8.9.0 on 7/6/2022
4c378 - feat: new function (#1756)

Released under the MIT License.