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

92
Views
How to make textarea expand when click into it?

I am trying to create onClick function that when user click into textarea it auto fully expand.

Here is my code base:

class DynamicWidthInput extends React.Component {
  componentDidMount() {
    const { id, value } = this.props;
    resizable(document.getElementById(id), 16, value);
  }

  componentDidUpdate(prevProps) {
    const { id, value } = this.props;

    if (this.props.value !== prevProps.value) {
      resizable(document.getElementById(id), 16, value);
    }
  }

  render() {
    const { id, placeholder, type, onChange, value, error, size } = this.props;
    if (type === "textarea") {
      return (
        <div style={{ display: "inline-block", verticalAlign: "top" }}>
          <textarea
            className={`input dynamic-input dynamic-textarea ${size}`}
            id={id}
            onChange={onChange}
            placeholder={placeholder}
            value={value}
            wrap="soft"
            maxLength="1000"
            {...this.props}
          />
          {error && <p className="help is-danger">{error.message}</p>}
        </div>
      );
    }
   ...
  }
}

export default DynamicWidthInput;

Here is how I display textarea:

   <DynamicWidthInput
      id="addLoanClause"
      value={addLoanClause}
      type="textarea"
      placeholder="1000 characters"
      error={showErrors && getError("addLoanClause")}
      onChange={e =>
        handleDynamicStateChange(e, setAddLoanClause)
      }
      size={"xxl"}
      rows="5"
    />{" "}

Here is how my project look like:

enter image description here

Expected fully display like this: enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you can use this style.

textarea {
    transition: all .3s ease;
    height: 100px;
}

textarea:focus {
    height: 300px;
}
about 4 years ago · Juan Pablo Isaza Report
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!