npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

fit-textarea

1.1.0 • Public • Published

fit-textarea Build Status

Automatically expand a <textarea> to fit its content, in a few bytes

Install

npm install fit-textarea

Setup

const fitTextarea = require('fit-textarea');
import fitTextarea from 'fit-textarea';
<textarea rows="3">Use the rows attribute to set its minimum height</textarea>

Usage

Once, one element

const textarea = document.querySelector('textarea');
fitTextarea(textarea);

As the user types

One element

const textarea = document.querySelector('textarea');
fitTextarea.watch(textarea);

Array/NodeList/Iterable of elements

const textareas = document.querySelectorAll('textarea');
fitTextarea.watch(textareas);

With a selector

The selector is run once, so it's equivalent to the example above.

fitTextarea.watch('textarea');

Related

  • indent-textarea - Add editor-like tab-to-indent functionality to
  • delegate-it - DOM event delegation, in <1KB. Can be used to attach one fit-textarea to many elements.
  • Refined GitHub - Uses this module.

install

npm i fit-textarea

Downloadsweekly downloads

168

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability