1.0.1 • Published 3 months ago

autosize-textarea v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

Autosize Textarea

The autosize-textarea component in action

Description

A simple textarea component that automatically resizes to fit its content.

Installation

npm install autosize-textarea

Usage

<head>
  <script type="module" src="./node_modules/autosize-textarea/autosize-textarea.js"></script>
</head>
<body>
  <autosize-textarea>
    <textarea rows="1" placeholder="Type something here..."></textarea>
  </autosize-textarea>
</body>

Gotchas

rows attribute

The web component applies the rows attribute to the textarea element when it is first created, which sets the initial height to fit the content. Becuase the component could register after the textarea is rendered on the page, you may see the textarea change height once the component registers.

To mitigate this, you can apply the rows attribute to the textarea element yourself, or set the rows attribute to 1 in the html.


Sponsor

Learn to build a component library using minimal tech with Component Odyssey. As a result, you'll:

  • Become a more future-proof web developer
  • Build components that your users will love
  • Boost your career opportunities
  • Learn to do more with less

1.0.1

3 months ago

1.0.0

5 months ago