david1 pro asked 7 years ago


Is there a way to auto grow text area inputs? I would at least like to have the text area be manually sizable by dragging the lower right corner.

david1 pro answered 7 years ago


Hi Adrian - That's exactly what I was looking for. Thanks!

Adrian Sawicki free answered 7 years ago


Hello David, You can add your own class to text-area and put into it resize: both !important. It will override MDB styles. Another option is to add your own class with padding: 0.5rem 0 !important to override styles and add such function to your JavaScript file:
jQuery.fn.extend({
  autoHeight: function () {
    function autoHeight_(element) {
      return jQuery(element)
        .css({ 'height': 'auto', 'overflow-y': 'hidden' })
        .height(element.scrollHeight);
    }
    return this.each(function() {
      autoHeight_(this).on('input', function() {
        autoHeight_(this);
      });
    });
  }
});

$('textarea').autoHeight();
Regards

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags