@gdo-bzh/textarea-autosize

A textarea component which automatically adjust its height on keyboard and window resize events

Usage no npm install needed!

<script type="module">
  import gdoBzhTextareaAutosize from 'https://cdn.skypack.dev/@gdo-bzh/textarea-autosize';
</script>

README

version

textarea-autosize

NPM JavaScript Style Guide

A textarea component which automatically adjust its height on keyboard and window resize events

Install

yarn add @gdo-bzh/textarea-autosize react

Usage

import React from 'react'

const Example: React.FC = () =>  (<TextareaAutosize autofocus autoselect placeholder="type text" />)

Types

type Props = Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'rows'> & State

type State = {
  /**
   * true to autoselect text content at initialize
   */
  autoselect?: boolean;
  /**
   * the value of an <textarea> element
   */
  value?: React.TextareaHTMLAttributes<HTMLTextAreaElement>['value'];
  /**
   * Minimum number of rows to display. Default value is 1
   */
  minRows?: number;
  /**
   * Maximum number of rows to display.
   */
  maxRows?: number;
}

License

MIT © gdo-bzh