New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fit-textarea

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fit-textarea

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

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fit-textarea

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

Try the demo!

Features:

  • Small
  • No layout thrashing (no DOM changes unless necessary)
  • You can set a minimum height (via rows attribute or height CSS property)
  • If the field is resizable, the new size will be treated as minimum height

Install

npm install fit-textarea

Setup

// This module is only offered as a ES Module
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');
  • indent-textarea - Add editor-like tab-to-indent functionality to , 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.

Keywords

FAQs

Package last updated on 12 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc