Recipe: Textarea + autoresize
A zero-dependency textarea that grows with its content. No libraries, no event handlers — just CSS grid trickery.
The invisible div mirrors the textarea content, forcing the grid row to expand.
How it works
- Both the
textareaand a hiddendivsit on the same CSS grid cell. - The div is
invisiblebut still takes up space, so the row height matches the content. - No JavaScript resize observer, no
onInputhandler. Pure CSS. - Works in every modern browser. The
rows=1sets the minimum height.