A simple AlpineJS plugin for autosizing textareas
npm install @marcreichel/alpine-autosize
A little Alpine.js plugin to automatically resize a textarea to fit its content.
Include the following tag in the of your document, just before Alpine.
``html`
`shell`
npm install @marcreichel/alpine-autosize
Add the x-autosize directive to your project by importing the package before starting Alpine.
`js
import Alpine from 'alpinejs';
import Autosize from '@marcreichel/alpine-autosize';
Alpine.plugin(Autosize);
Alpine.start();
`
To let the textarea automatically resize, add the x-data and x-autosize directives to the
`html`
To add additional height to the textarea - which might be necessary in some occasions - you can do so using the
"padding" modifier like so (only px values are supported):
`html``
This adds additional 10px to the textarea height. You can provide any integer which best suits your needs.
Copyright (c) 2022 Marc Reichel and contributors.
Licensed under the MIT license, see LICENSE for details.