Documentation v1.0.3



Autosize is a small, stand-alone script to automatically adjust textarea height. For full documentation please check the plugin's site.


Autosize's Javascript files are bundled in the global plugin bundles and globally included in all pages:
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css"/>
<script src="assets/plugins/global/plugins.bundle.js"></script>


  • Autosize's Javascript is globally included and bundled without our plugins bundle.
  • Autosize's is initialized by adding data-kt-autosize="true" HTML attribute within any textarea HTML element.
  • Autosize instances can also be controlled programmatically. See below for more info.
  • Autosize also supports event hooks. Please refer to the official documentation for more info.


Here's an example of the textarea automatically resizing base on the amount of text written in it.
Combine our extended .form-control CSS classes to create quick and solid textarea layouts.
<!--begin::basic autosize textarea-->
<div class="rounded border d-flex flex-column p-10">
    <label for="" class="form-label">Basic autosize textarea</label>
    <textarea class="form-control" data-kt-autosize="true"></textarea>
<!--end::basic autosize textarea-->

<!--begin::solid autosize textarea-->
<div class="rounded border d-flex flex-column p-10">
    <label for="" class="form-label">Solid autosize textarea</label>
    <textarea class="form-control form-control form-control-solid" data-kt-autosize="true"></textarea>
<!--end::solid autosize textarea-->

Markup Reference

Autosize uses HTML attributes to initialize the autosize function. Here are the references for each below
HTML Attribute references
Name Type Description
data-kt-autosize mandatory Enables the current element as the Autosize component. Accepts true or false values.


All Autosize components can be initialized automatically through HTML attributes. However, it can also be programmatically intialized by ignoring the HTML attribute and manually initializing it via Javascript.
Name Description
Static Methods
Initialization Initializes Autosize instances by selecting the element required. This method can be used to initialize dynamicly populated Autosize instances(e.g: after Ajax request).
// Single node   
const autosize_element = document.querySelector('#kt_autosize');

// Nodelist
const autosize_elements = document.querySelectorAll('.kt_autosize');

// jQuery
Public Methods
update Triggers the height adjustment for an assigned textarea element. Autosize will automatically adjust the textarea height on keyboard and window resize events. There is no efficient way for Autosize to monitor for when another script has changed the textarea value or for changes in layout that impact the textarea element.
// Change value
autosize_element.vlaue = "some value";
destroy Removes Autosize and reverts any changes it made to the textarea element.
Preview Get Help Buy Now