
Description
react-textarea-autosize is a drop-in replacement for the textarea element in React that resizes itself as its content changes. The README describes it as a native React version of the popular jQuery Autosize plugin. The package is small, at around 1.3 KB minified and gzipped, and the README says it supports Internet Explorer 9 and above. It is installed from npm. It accepts the special props maxRows, which caps how far the box can grow, and minRows, which sets the minimum number of rows shown. It also accepts onHeightChange, a function called with the new height whenever the height changes, with an object containing extra information such as the row height. The cacheMeasurements prop reuses earlier measurements when computing height, and it is off by default. Apart from those props, the component accepts all the props a textarea does, including style, onChange and value, and passes HTML attributes through to the inner textarea. The FAQ covers focusing the field, which needs a ref to the inner textarea, and autofocus. It also covers testing with Jest and react-test-renderer, where refs are not provided, and explains how to supply a mocked ref in tests.…
Highlights
- Grows with content, native React
- maxRows and minRows limits
- onHeightChange callback
- About 1.3 KB minified and gzipped
Ratings & Reviews
No ratings yet
Be the first to rate react-textarea-autosize.
People also visit

react-autosize-textarea
replacement for built-in textarea which auto resizes itself

rich-textarea
A small customizable textarea for React to colorize, highlight, decorate texts

@webscopeio/react-textarea-autocomplete
Offers autocomplete over textarea in style of GitHub
react-textarea-autosize FAQ
What is react-textarea-autosize?
A drop-in replacement for the React textarea that resizes itself as the content changes.
How do I install it?
Run npm install react-textarea-autosize, then use the component in place of a textarea.
How do I limit its height?
Use the maxRows prop to cap growth and minRows to set a minimum, and onHeightChange to react to height changes.
Which browsers does it support?
The README says it supports Internet Explorer 9 and above.
How do I focus it?
Get a ref to the inner textarea and call focus on it. All HTML attributes are passed through to the inner textarea, so autofocus also works.
What are the best react-textarea-autosize alternatives?
Popular alternatives to react-textarea-autosize include react-autosize-textarea, react-input-autosize and react-textarea-autosize. See all react-textarea-autosize alternatives












