Documentation v1.0.4

Preview 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 textareaHTML 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 textareaautomatically resizing base on the amount of text written in it.
Combine our extended .form-controlCSS classes to create quick and solid textarealayouts.
<!--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 trueor falsevalues.

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);
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
From guides and how-tos, to live demos and code examples to get started right away.
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.
What's New
Latest features and improvements added with our users feedback in mind.
Buy now