Open In App

Onsen UI CSS Component Material Switch

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. In this article, we will see the Onsen UI CSS Component Material Switch.

Onsen UI CSS Component Material Switch is used to create the material switch using Onsen UI Switch classes. To create the material switch, we will use the below classes.



Onsen UI CSS Component Material Switch Classes:

Syntax:



<label class="switch switch--material">
    <input type="checkbox"
        class="switch__input 
           switch--material__input">
        <div class="switch__toggle 
                switch--material__toggle">
            <div class="switch__handle 
                switch--material__handle">
            </div>
        </div>
</label>

Example 1: The following example demonstrates the Onsen UI CSS Component Material Switch.




<!DOCTYPE html>
<html>
  
<head>
    <!-- CDN links of Onsen UI library -->
    <link rel="stylesheet" href=
    <link rel="stylesheet" href=
    <script src=
    </script>
</head>
  
<body>
    <center>
        <h2 style="color: green;">
            GeeksforGeeks
        </h2>
        <strong>
            Onsen UI CSS Component Material Switch
        </strong> <br> <br>
  
        <label class="switch switch--material">
            <input type="checkbox" 
                   class="switch__input 
                   switch--material__input">
            <div class="switch__toggle 
                        switch--material__toggle">
                <div class="switch__handle 
                            switch--material__handle">
                </div>
            </div>
        </label>
    </center>
</body>
  
</html>

Output:

 

Example 2: The following example demonstrates the Onsen UI CSS Component Material Switch using the disabled attribute.




<!DOCTYPE html>
<html>
  
<head>
    <!-- CDN links of Onsen UI library -->
    <link rel="stylesheet" href=
    <link rel="stylesheet" href=
    <script src=
    </script>
</head>
  
<body>
    <center>
        <h2 style="color: green;">
            GeeksforGeeks
        </h2>
        <strong>
            Onsen UI CSS Component Material Switch
        </strong> <br> <br>
  
        <label class="switch switch--material">
            <input type="checkbox" 
                   class="switch__input 
                   switch--material__input">
            <div class="switch__toggle 
                        switch--material__toggle">
                <div class="switch__handle 
                            switch--material__handle">
                </div>
            </div>
        </label>
  
        <label class="switch switch--material">
            <input type="checkbox" 
                   class="switch__input 
                   switch--material__input"
                   disabled>
            <div class="switch__toggle 
                        switch--material__toggle">
                <div class="switch__handle 
                            switch--material__handle">
                </div>
            </div>
        </label>
    </center>
</body>
  
</html>

Output:

 

Reference: https://onsen.io/v2/api/css.html#switch-category


Article Tags :