svelte-autosize
v1.1.5
Published
Svelte action to automatically adjust textarea height.
Downloads
10,517
Readme
svelte-autosize
Svelte action to automatically adjust textarea height to match its contents.
Simply wraps autosize by Jack Moore in a Svelte action.
See the autosize website for additional documentation.
Install via NPM
npm install svelte-autosize
Usage
<script>
import autosize from 'svelte-autosize';
</script>
<textarea use:autosize></textarea>
If you need to reset the textarea height, you can use autosize.update(textarea)
. For example:
<script>
import {tick} from 'svelte';
import autosize from 'svelte-autosize';
let textarea;
let value = '';
async function reset() {
value = '';
await tick();
autosize.update(textarea);
}
</script>
<textarea use:autosize bind:this={textarea} bind:value></textarea>
<button on:click={reset}>Reset</button>