Open In App

Onsen UI Switch CSS Components

In this article, we will learn how to include switch components using Onsen UI. Onsen UI CSS is used to create beautiful HTML components. It is one of the most efficient ways to create HTML5 hybrid components that are compatible with both mobile and desktop.

Switch CSS Components The switch is a kind of toggle button that is used to create a button that will shift from one place to another on click and do some functionality.



Syntax:

<element-name class="class-name">...</element-name>

Classes Used:



Example 1: In the below code, we will make use of the above classes to make a switch.




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href=
    <link rel="stylesheet" href=
    </script>
 
    <style>
        #heading {
            color: green;
        }
 
        #title {
            font-style: bold;
        }
    </style>
</head>
 
<body>
    <center>
        <h1 id="heading">
            GeeksforGeeks
        </h1>
        <h3>A computer science portal for geeks</h3>
        <strong id="title">
            Onsen UI CSS Component
        </strong>
        <br>
 
        <label class="switch">
            <input type="checkbox" class="switch__input">
            <div class="switch__toggle">
                <div class="switch__handle"></div>
            </div>
        </label>
    </center>
</body>
 
</html>

 Output:

 

Example 2: In the below code, we will make use of the above classes to make a switch.




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href=
    <link rel="stylesheet" href=
    </script>
 
    <style>
        body {
            background-color: lightgrey;
        }
 
        #heading {
            color: green;
        }
 
        #title {
            font-style: bold;
        }
    </style>
</head>
 
<body>
    <center>
        <h1 id="heading">
            GeeksforGeeks
        </h1>
        <h3>A computer science portal for geeks</h3>
        <strong id="title">
            Onsen UI CSS Component
        </strong>
        <br><br>
 
        <label class="switch">
            <input type="checkbox" class="switch__input">
            <div class="switch__toggle">
                <div class="switch__handle"></div>
            </div>
        </label><br><br>
        <label class="switch">
            <input type="checkbox" class="switch__input">
            <div class="switch__toggle">
                <div class="switch__handle"></div>
            </div>
        </label><br><br>
        <label class="switch">
            <input type="checkbox" class="switch__input">
            <div class="switch__toggle">
                <div class="switch__handle"></div>
            </div>
        </label>
    </center>
</body>
 
</html>

Output:

 

Reference: https://onsen.io/v2/api/css.html


Article Tags :