Skip to content
Related Articles

Related Articles

Onsen UI CSS Component Material Switch

View Discussion
Improve Article
Save Article
  • Last Updated : 29 Jun, 2022

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:

  • switch–material: This class is used to create the material switch.
  • switch–material__input: This class is used to create the material switch input.
  • switch–material__toggle: This class is used to create the material switch toggle.
  • switch–material__handle: This class is used to create the material switch handle.

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.

HTML




<!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.

HTML




<!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


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!