Skip to content
Automatically expand a <textarea> to fit its content, in a few bytes
Branch: master
Clone or download
Latest commit aa87d3b Mar 23, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Initial version Mar 14, 2019
.gitignore Initial version Mar 14, 2019
index.ts Fix a possible TS namespace bug Mar 22, 2019
license User lowercase filename Mar 15, 2019
package.json 1.1.0 Mar 22, 2019

fit-textarea (size) (status)

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


npm install fit-textarea


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


Once, one element

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

As the user types

One element

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

Array/NodeList/Iterable of elements

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

With a selector

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


  • indent-textarea - Add editor-like tab-to-indent functionality to <textarea>, in a few bytes.
  • delegate-it - DOM event delegation, in <1KB. Can be used to attach one fit-textarea to many elements.
  • Refined GitHub - Uses this module.
You can’t perform that action at this time.