How to Auto Resize textarea in Materializecss in Javascript

Viewed 438

I am using Materializecss with React.js. The document only gives jQuery implementation of auto-resizing of textarea instead of pure Javascript.

 $('#textarea1').val('New Text');
  M.textareaAutoResize($('#textarea1'));

How can I reach it with pure Javascript?

1 Answers

To use Materialize with React, you should use npm install materialize-css@next npm install react-materialize where you can use components

Textareas allow larger expandable user input. The border should light up simply and clearly indicating which field the user is currently editing. Textareas will auto resize to the text inside. Source:

<Row>
  <Textarea
    id="Textarea-12"
    l={12}
    m={12}
    s={12}
    xl={12}
  />
</Row>

Learn more about React Materilize

Related