Metronic Documentation | Keenthemes
logo
The World’s #1 Bootstrap 5 HTML, VueJS, React, Angular & Laravel
Admin Dashboard Ecosystem

This is Metronic 7 documentation!

Upon purchase you can get Metronic 7 version from our Github Repository.
Request Github access
The new Metronic 8 is now available with the most advanced Bootstrap 5, VueJS, React and Laravel foundation with a solid light and dark mode design system, extensive utility classes and custom made in-house components.
View Metronic 8 documentation

To use most of the Metronic build tools, Node.js LTS version is required. Version 14.x LTS is recommended. Some of the plugins and framework in Metronic v7 does not support the latest Node.js version. https://nodejs.org/en/

Toggle

Overview

KTToggle is a Metronic's custom plugin defined in [metronic]/theme/html/[demo]/src/js/components/base/toggle.js.

Initialization

First parameter is the id, class, or tag of the HTML element. The second parameter is for the options.

var _toggleObject = new KTToggle(_toggleElement, {
  target: KTUtil.getBody(),
  targetState: 'topbar-mobile-on',
  toggleState: 'active',
});

Options

var options = {
  target: KTUtil.getBody(),
  targetState: 'topbar-mobile-on',
  toggleState: 'active',
}; 
Field Type Description
target string

The target for the class name changed

Sample
target: 'body'
targetState string

The state class name to be added to the target

Sample
targetState: 'topbar-mobile-on'
toggleState string

The active state for the toggler

Sample
toggleState: 'active'

API Methods

Method Description
setDefaults(options)

Set default options

getState()

Get toggle state

toggle()

Toggle

toggleOn()

Toggle on

toggleOff()

Toggle off

on(name, handler)

Attach event @returns {KTToggle}

one(name, handler)

Attach event that will be fired once @returns {KTToggle}

Think About The Future, Stay Connected With Us
The More We Learn, The More We Are Able To Innovate & To Develop