https://github.com/matthiasmullie/jquery-autoexpand
Auto-expands textareas so they grow as you type
https://github.com/matthiasmullie/jquery-autoexpand
Last synced: about 1 month ago
JSON representation
Auto-expands textareas so they grow as you type
- Host: GitHub
- URL: https://github.com/matthiasmullie/jquery-autoexpand
- Owner: matthiasmullie
- License: mit
- Created: 2014-10-23T08:35:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-09T12:11:14.000Z (over 6 years ago)
- Last Synced: 2025-03-28T03:32:34.355Z (about 2 months ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jquery-autoexpand
[](https://www.npmjs.com/package/jquery-autoexpand)
[](https://www.npmjs.com/package/jquery-autoexpand)
[](https://github.com/matthiasmullie/jquery-autoexpand/blob/master/LICENSE)A textarea will automatically grow and shrink in height as you add or remove content to it.
* The textarea will never shrink smaller than its original height
* The textarea will never grow beyond the bottom edge of the window. Instead, a scroll bar show up in the textarea as more text is added to the textarea.## Demo
Try it out here: http://www.mullie.eu/jquery-autoexpand/
## Usage
```javascript
$('textarea').autoExpand();
```Or if you want to customize some of the options:
```javascript
$('textarea').autoExpand({ animationTime: 0, windowPadding: 100 });
```## Remove
If you no longer need the textarea to auto-expand and you want to reset it:
```javascript
$('textarea').autoExpand('destroy');
```## Options
Options can be passed in as a `{ key: value }` object literal. Available options are:
| property | default value | description |
|---------------|:-------------:|---------------------------------------------------------------|
| animationTime | 50 | Time in milliseconds to animate to new height |
| windowPadding | 20 | Amount of pixels to preserve between textarea & window bottom |You can remove the auto-expander from a textarea by passing 'destroy' (as string, not in an object literal).
## Installation
Install this package via [npm](https://www.npmjs.org/):
```sh
npm install jquery-autoexpand
```Or simply copy jquery.autoexpand.js into your project.
## License
jquery-autoexpand is [MIT](http://opensource.org/licenses/MIT) licensed.