Documentation v8.0.15

Overview

Swapper is an exclusive component of Metronic  that provides a simple and elegent solution to re-position HTML elements based on specific screen breakpoints.

Usage

Swapper's Javascript bundles are globally included in all pages.
<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css"/>
<script src="assets/js/scripts.bundle.js"></script>

Initialization

  • Swapper is initialized by adding data-kt-swapper="true"to the root of the HTML that will be swapped positions.
  • Add data-kt-swapper-mode="prepend"to the root HTML element to configure if the swapped element would be appended or prepended within the parent.
  • Add data-kt-swapper-parent="{default: '#parent_container_1', lg: '#parent_container_2'}"to identify the parent containers that the swapping component will be added into based on Bootstrap's breakpoint sizes.
  • Swapper instances can also be controlled programmatically. See below for more info.

Basic Example

Here's a basic example of Swapper. Try the demo below by adjusting your browser width.
All child elements within the Swapper component will also swap parents.
Parent Element 1
This HTML element will swap parent elements on different screen breakpoints
Parent Element 2
Parent Element 3
Parent Element 4
<div class="row g-10">
    <div class="col-lg-6">
        <div class="bg-light-primary h-100 p-5" id="kt_docs_swapper_parent_1">
            <div class="fw-boldest">Parent Element 1</div>

            <!--begin::Swapper-->
            <div class="mt-3"
                data-kt-swapper="true"
                data-kt-swapper-mode="append"
                data-kt-swapper-parent="{
                    default: "#kt_docs_swapper_parent_4",
                    md: "#kt_docs_swapper_parent_3",
                    lg: "#kt_docs_swapper_parent_2",
                    xl: "#kt_docs_swapper_parent_1"
                }">
                This HTML element will swap parent elements on different screen breakpoints
            </div>
            <!--end::Swapper-->
        </div>
    </div>
    <div class="col-lg-6">
        <div class="bg-light-info h-100 p-5" id="kt_docs_swapper_parent_2">
            <div class="fw-boldest">Parent Element 2</div>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="bg-light-warning h-100 p-5" id="kt_docs_swapper_parent_3">
            <div class="fw-boldest">Parent Element 3</div>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="bg-light-success h-100 p-5" id="kt_docs_swapper_parent_4">
            <div class="fw-boldest">Parent Element 4</div>
        </div>
    </div>
</div>

Markup Reference

Swapper uses HTML attributes to set specific configurations. Here are the references for each below
HTML Attribute references
Name Type Description
data-kt-swapper mandatory Enables the current element as the Swapper component. Accepts trueor falsevalues.
data-kt-swapper-mode optional Defines the re-positioning method. Accepts appendor prepend. Defaults to append.
data-kt-swapper-parent mandatory
Defines the parent element to be swapped into at specific Bootstrap breakpoints. This is compatible with Bootstrap's standard breakpoint sizing (eg: sm, md, lg, xl) with a similar pxvalues. For responsive options, this attribute value must be written as an object string to enable multiple responsive breakpoints.
For example: {default: '#parent_container_1', lg: '#parent_container_2'}that the swapper component will swap the parent element from #parent_container_1to #parent_container_2when the screen grows from smaller sizes to lgsize or bigger and vice versa.

Methods

All Swapper components are initialized automatically, however the following are Password Meter's functionality methods for more control.
Name Description
Static Methods
getInstance(DOMElement element) Get the Swapper instance created
var swapperElement = document.querySelector("#kt_swapper_control");
var swapper = KTSwapper.getInstance(swapperElement);
Public Methods
update Forces the Swapper component to update and re-position depending on screen size.
swapper.update();

Activity Logs

There are 2 new tasks for you in “AirPlus Mobile APp” project:
Added at 4:23 PM by
img
Meeting with customer
Application Design
img
img
A
In Progress
View
Project Delivery Preparation
CRM System Development
img
B
Completed
View
Invitation for crafting engaging designs that speak human workshop
Sent at 4:23 PM by
img
Task #45890merged with #45890in “Ads Pro Admin Dashboard project:
Initiated at 4:23 PM by
img
3 new application design concepts added:
Created at 4:23 PM by
img
New case #67890is assigned to you in Multi-platform Database Design project
Added at 4:23 PM by
Alice Tan
You have received a new order:
Placed at 5:05 AM by
img

Database Backup Process Completed!

Login into Metronic Admin Dashboard to make sure the data integrity is OK
Proceed
New order #67890is placed for Workshow Planning & Budget Estimation
Placed at 4:23 PM by
Jimmy Bold
Pic
Brian Cox 2 mins
How likely are you to recommend our company to your friends and family ?
5 mins You
Pic
Hey there, we’re just writing to let you know that you’ve been subscribed to a repository on GitHub.
Pic
Brian Cox 1 Hour
Ok, Understood!
2 Hours You
Pic
You’ll receive notifications for all issues, pull requests!
Pic
Brian Cox 3 Hours
You can unwatch this repository immediately by clicking here: Keenthemes.com
4 Hours You
Pic
Most purchased Business courses during this sale!
Pic
Brian Cox 5 Hours
Company BBQ to celebrate the last quater achievements and goals. Food and drinks provided
Just now You
Pic
Pic
Brian Cox Just now
Right before vacation season we have the next Big Deal for you.

Explore Metronic

Demo1

Demo2

Demo3

demo
Coming soon

Demo4

demo
Coming soon

Demo5

Demo6

demo
Coming soon

Demo7

demo
Coming soon

Demo8

demo
Coming soon

Demo9

demo
Coming soon

Demo10

demo
Coming soon

Demo11

demo
Coming soon

Demo12

demo
Coming soon

Demo13

demo
Coming soon

Demo14

demo
Coming soon

Demo15

demo
Coming soon