Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-autosize-textarea

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-autosize-textarea

replacement for built-in textarea which auto resizes itself

  • 0.3.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
118K
decreased by-14.52%
Maintainers
1
Weekly downloads
 
Created
Source

React Autosize Textarea

A light replacement for built-in <textarea /> component which automatically adjusts its height to match the content.

NB: It does not require any polyfill

import ReactDOM from 'react-dom';
import TextareaAutosize from 'react-autosize-textarea';

ReactDOM.renderComponent(
  <TextareaAutosize {...textareaProps} onResize={(e) => {}} />,
  document.body
);

Install

npm install --save react-autosize-textarea

Demo

Live Demo

More Examples

Usage

You can pass any prop you're allowed to use with the default React textarea (valueLink too).

You can also pass the optional callback onResize which will be triggered at any resize with the autosize:resized event object:

function onResize(event) {
  console.log(event.type); // -> "autosize:resized"
}

<TextareaAutosize onResize={onResize} />
Set min/max height

You can set minHeight and maxHeight through CSS or inline-style as usual:

<TextareaAutosize style={{ minHeight: 20, maxHeight: 80 }} /> // min-height: 20px; max-height: 80px;

NB: you may need to take into account borders and/or padding.

In addition to minHeight, you can force TextareaAutosize to have a minimum number of rows by passing the prop rows:

<TextareaAutosize rows={3} /> // minimun height is three rows

Browser Compatibility

ChromeFirefoxIESafariAndroid
YesYes9+Yes4+

Credits

This module is based on the very popular autosize script written by Jack Moore.

Check out his repo or website for more documentation.

Keywords

FAQs

Package last updated on 22 Jan 2017

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