Auto-Growing Textarea
A copy-paste form states component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Form StatesHTMLCSSany framework
Copy into your project
HTML
<!-- field-sizing: content (Chromium 123+) grows the box with input, no JS.
Where unsupported it degrades to a normal fixed-size resizable textarea. -->
<div class="nuda-fs2-autogrow-textarea">
<label for="fs2-note" class="nuda-fs2-autogrow-textarea__label">Note</label>
<textarea id="fs2-note" class="nuda-fs2-autogrow-textarea__input" rows="1">Type here — the box grows with your text.
No JS needed for the resize itself.</textarea>
</div>CSS
.nuda-fs2-autogrow-textarea {
width: 100%;
max-width: 270px;
display: flex;
flex-direction: column;
gap: 6px;
font-family: ui-sans-serif,system-ui,sans-serif;
}
.nuda-fs2-autogrow-textarea__label {
font-size: 12px;
font-weight: 600;
color: #cfcfcf;
}
.nuda-fs2-autogrow-textarea__input {
width: 100%;
min-height: 44px;
max-height: 220px;
padding: 11px 12px;
background: #161616;
border: 1px solid rgba(255,255,255,.12);
border-radius: 9px;
color: #fafafa;
font-size: 13px;
font-family: inherit;
line-height: 1.4;
box-sizing: border-box;
resize: none;
field-sizing: content;
transition: border-color .2s,box-shadow .2s;
}
.nuda-fs2-autogrow-textarea__input:focus-visible {
outline: 2px solid #e4ff54;
outline-offset: 2px;
border-color: #e4ff54;
}
@media (prefers-reduced-motion:reduce) {
.nuda-fs2-autogrow-textarea__input {
transition: none !important;
}
}
How to use Auto-Growing Textarea
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.