Use KTUI JavaScript with clear import and initialization modes for modern apps.
Use the UMD bundle when you want global usage with automatic full initialization.
<!DOCTYPE html>
<html>
<body>
<h1>Hello world!</h1>
<script src="./node_modules/@keenthemes/ktui/dist/ktui.min.js"></script>
</body>
</html>@keenthemes/ktui/components/<name>: import one component and initialize only that component.@keenthemes/ktui/core: side-effect-free entry for importing multiple components without auto-init.@keenthemes/ktui/init-all: explicit full-library initialization (legacy-style behavior on purpose).@keenthemes/ktui (root): legacy-compatible entry that auto-initializes all components.For production apps, prefer selective imports and explicit per-component initialization.
import { KTTogglePassword } from '@keenthemes/ktui/components/toggle-password';
KTTogglePassword.init();Data attributes still work and are a convenient way to bind behavior to markup.
<button data-kt-tooltip="true" id="my_tooltip">
Toggle Tooltop
<div class="kt-tooltip" data-kt-tooltip-content="true">
Hey, a delightful tooltip is here!
</div>
</button>If you prefer manual control, avoid the data attribute auto-init pattern and instantiate directly.
const tooltipEl = document.querySelector('#my_tooltip');
const options = {
placement:'bottom-start'
};
const tooltip = new KTTooltip(tooltipEl, options);
tooltip.show();
tooltip.hide();
tooltip.toggle();Use KTComponents.init() when you intentionally want broad initialization (for example, after large DOM updates).
KTComponents.init();init() methods after route/content changes.@keenthemes/ktui root imports to @keenthemes/ktui/components/<name> (or @keenthemes/ktui/core) for better control.@keenthemes/ktui/init-all with frequent broad KTComponents.init() calls; prefer targeted re-init.See TypeScript for typed examples and import patterns.