v-autosize is a lightweight Vue 3 directive designed to wrap the standalone `autosize` library, enabling `<textarea>` HTML elements to automatically adjust their height to perfectly fit their content. The current stable version, 2.0.1, is built specifically for Vue 3. Users requiring Vue 2 compatibility should refer to `v-autosize@1`. This package differentiates itself from other solutions like `vue-autosize` and `vue-textarea-autosize` by being actively maintained for the current Vue ecosystem (Vue 3) and providing a simple, directive-based integration rather than a component-based one, ensuring minimal boilerplate. Release cadence is typically tied to updates in the core `autosize` library or significant Vue ecosystem changes, prioritizing stability and a small bundle size.
npm install v-autosizeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to globally register the `v-autosize` directive plugin and apply it to a `<textarea>` element within a Vue 3 application, enabling automatic height adjustment.
For Vue 2 projects, run `npm install v-autosize@1` or `yarn add v-autosize@1`. For Vue 3, ensure you are on `v-autosize@2` or newer.
Ensure `v-autosize` is used only on `<textarea>` elements. If you need it for a custom component, ensure the component internally renders a `<textarea>` and you can pass the directive to it or wrap it.
Use `import autosizePlugin from 'v-autosize/src/plugin.js';` for global registration with `app.use()`.
Register the directive. For local use: `import autosize from 'v-autosize'; export default { directives: { autosize } }`. For global use: `import autosizePlugin from 'v-autosize/src/plugin.js'; app.use(autosizePlugin);`Verify that the `v-autosize` directive is exclusively used on `<textarea>` HTML elements and that the element is present in the DOM when the directive initializes.