A lightweight, dependency-free JavaScript library for automatically resizing form elements (textareas, inputs, selects) to fit their content.
Stretchy is a lightweight JavaScript library that automatically resizes form elements—like textareas, inputs, and select menus—to fit their content dynamically. It solves the common problem of form controls with fixed dimensions that don't adjust to user input, improving usability without requiring complex CSS or manual scripting.
Frontend developers and designers building forms or interactive UIs who need form elements to resize automatically based on content, especially those working with vanilla JavaScript, web components, or Shadow DOM.
Developers choose Stretchy for its minimal footprint, zero dependencies, and ease of integration—it works out-of-the-box with HTML attributes alone, respects existing CSS constraints, and automatically handles dynamically added elements via mutation observers.
Form element autosizing, the way it should be
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
At less than 1.5KB minified and gzipped with no dependencies, Stretchy adds minimal overhead, as emphasized in the README's features.
Uses mutation observers to automatically resize newly added form elements without manual intervention, ideal for dynamic content.
Can be set up entirely via HTML attributes like `data-filter`, allowing integration without writing JavaScript, as shown in the usage section.
Respects existing CSS constraints such as min/max-width/height and transitions, ensuring seamless integration with your styles.
v1 had issues with Internet Explorer and required polyfills for mutation observers, and v2 may not support very old browsers, as noted in the browser support section.
When including Stretchy via a script element, setting filters via JavaScript can cause race conditions if not timed correctly, a limitation admitted in the README's filter section.
The API is minimal, which might not suffice for advanced use cases needing more control over resizing logic or event integration.