Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
React textarea grows but doesn't shrink, how to make it shrink?

I have this React component, which successfully grows the textarea.

.textarea {
  resize: none;
  overflow: hidden;
  box-sizing: border-box;
}


export default function Textarea({
  className,
  onChange,
  defaultValue,
  ...attrs
}) {
  const handleInput = (e) => {
    const h = e.target.scrollHeight
    e.target.style.height = '0px'
    e.target.style.height = `${h}px`
    onChange?.(e)
  }

  return (
    <textarea {...attrs} defaultValue={defaultValue} onInput={handleInput} className={styles.textarea} />
  )
}

How do I get it to shrink though, it only grows?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!