Search code examples
ionic-frameworkionic5

Make ion-textarea resizable


The Ionic 5 documentation says:

The textarea component accepts the native textarea attributes in addition to the Ionic properties.

But this does not apply to CSS properties of the native textarea, so how is it possible to make the ion-textarea element resizable?

enter image description here


Solution

  • You can try using the below plugin:

    OR

    • npm i ngx-autosize
    • import { AutosizeModule } from 'ngx-autosize';

    below is the code i used in ionic/angular to make the ion-textarea resize:

    <ion-textarea
      [minRows]="1"
      [maxRows]="5"
      autosize
      placeholder="Start writing..."
    ></ion-textarea>
    

    you need to import it in and imports array in app.module and page.module where you need to use it.