Skip to content

Instantly share code, notes, and snippets.

@tukkek
Last active October 13, 2025 14:24
Show Gist options
  • Select an option

  • Save tukkek/156a240c75c55c0125a0aaa0fe76318e to your computer and use it in GitHub Desktop.

Select an option

Save tukkek/156a240c75c55c0125a0aaa0fe76318e to your computer and use it in GitHub Desktop.
Module to automatically-resize text-area elements.
// no-longer needed after Fire-fox implements textarea{field-sizing:content;}
function update(element){
let rows=element.value.split('\n').length
if(rows<1) rows=1
element.setAttribute('rows',rows)
}
export function resize(element){
update(element)
element.addEventListener('input',()=>update(element))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment