# Documentation v8.0.38

Preview Downloads Purchase

# Overview

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

# Usage

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>

# Initialization

- 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 documentationfor more info.

# Basic

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.
Basic autosize textarea
Solid autosize textarea

    <!--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>
    </div>
    <!--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>
    </div>
    <!--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.

# Methods

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');
    autosize(autosize_element);

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

    // jQuery
    autosize($('.kt_autosize'));
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";
    autosize.update(autosize_element);
`destroy` | Removes Autosize and reverts any changes it made to the textarea element.
    autosize.destroy(autosize_element);

### Explore

### Metronic Licenses

License FAQs
Regular License
For single end product used by you or one client
$ 39
Extended License
For single SaaS app with paying users
$ 969
Custom License
Reach us for custom license offers.
Contact Us
Buy Now

### Metronic Demos

Demo 1
Demo 2
Demo 3
Demo 4
Demo 5
Demo 6
Demo 7
Demo 8
Demo 9
Demo 10
Demo 11
Demo 12
Demo 13
Demo 14
Demo 15
Demo 16
Demo 17
Demo 18
Demo 19
Demo 20
Demo 21
Demo 22
Coming soon
Coming soon

##### Learn & Get Inspired

## Support at devs.keenthemes.com

Join our developers community to find answer to your question and help others. FAQs
Get Support
Documentation & Videos
From guides and video tutorials, to live demos and code examples to get started.
Plugins & Components
Check out our 300+ in-house components and customized 3rd-party plugins.
Layout Builder
Build your layout, preview it and export the HTML for server side integration.
Metronic Downloads
Download your prefered framework and demo with one click.
What's New
Latest features and improvements added with our users feedback in mind.
Buy now