LeaVerou / stretchy

Form element autosizing, the way it should be
https://stretchy.verou.me/
Other
1.27k stars 87 forks source link
# Stretchy Form element autosizing, the way it should be!
# Features - **Handles multiple types of form controls** Textareas? Inputs? Select menus? You name it! - **Tiny footprint** [Less than 1.5KB](https://bundlephobia.com/package/stretchy) minified and gzipped! - **Automatically accounts for newly added controls** via mutation observers - **Restrict form controls by a selector** …or don’t and autosize all your form controls! - **Completely standalone** no jQuery or other dependencies - **Plays well with existing HTML/CSS** Follows placeholders, styling, `min/max-width/height` constraints, transitions - **No JS knowledge required** Everything can be configured just via HTML! - **[Works in all modern browsers](#browser-support)** ([v1 even works in old browsers](#v1-browser-support-notes)) - **Written in ESM** Available in ESM, CJS, and good ol' globals - **Works in Shadow DOM** Use it in your web components!
# Usage
## Good ol’ ` ``` If you include Stretchy this way it will run automatically and you don’t need to do anything else (unless you want to [customize which elements it applies to](#filter)).
## ESM (v2.0.0+) This method is ideal if you are including Stretchy as a dependency on a larger project and want to prevent any side effects. ```js import * as Stretchy from "https://stretchy.verou.me/dist/stretchy.min.js"; Stretchy.init(); ```
## CommonJS (v2.0.0+) A CommonJS build is also available. `require("stretchy")` should work on Node. ## Local files All three of the above methods can be used with your own local files as well. You can download Stretchy [here](https://www.jsdelivr.com/package/npm/stretchy). npm works like you’d expect too: ``` npm install stretchy ```
# Which elements does Stretchy resize? By default, Stretchy resizes all `