svelte-autosize
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

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>

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i svelte-autosize

Weekly Downloads

2,574

Version

1.1.5

License

MIT

Unpacked Size

3.32 kB

Total Files

5

Last publish

Collaborators

  • jesseskinner