Onsen UI CSS Component Material Switch
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 >
< 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 >
< 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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...