Onsen UI Segment CSS Components

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.

The segment is used to create a group of related content. Onsen UI CSS Segment is used to create the segment using the below classes.

Onsen UI CSS Component Basic Segment Classes:

  • segment: This class is used to create the segment.
  • segment__item: This class is used to create the segment item.
  • segment__input: This class is used to create the segment input.
  • segment__button: This class is used to create the segment buttons.

Onsen UI CSS Component Material Segment Classes:

  • segment–material: This class is used to create the material segment.
  • segment–material__item: This class is used to create the material segment item.
  • segment–material__input: This class is used to create the material segment input.
  • segment–material__button: This class is used to create the material segment button.

Syntax:

<div class="segment">...</div>

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

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!-- CDN links of Onsen UI library -->
    <link rel="stylesheet" href=
"https://unpkg.com/onsenui/css/onsenui.css">
    <link rel="stylesheet" href=
"https://unpkg.com/onsenui/css/onsen-css-components.min.css">
    <script src=
"https://unpkg.com/onsenui/js/onsenui.min.js">
    </script>
    <style>
        body{
            background-color:lightgreen;
        }
    </style>
</head>
  
<body>
    <center>
        <h2 style="color: green;">
            w3wiki
        </h2>
        <strong>
            Onsen UI CSS Component Segment
        </strong> <br> <br>
  
        <div class="segment" style="width:120px;">
            <div class="segment__item">
                <input type="checkbox" class="segment__input">
                <div class="segment__button">
                    DSA
                </div>
            </div>
  
            <div class="segment__item segment__item">
                <input type="checkbox" class="segment__input">
                <div class="segment__button">
                    Project
                </div>
            </div>
        </div>
    </center>
</body>
</html>


Output:

 

Example 2: The following example demonstrates the Onsen UI CSS Component Segment.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!-- CDN links of Onsen UI library -->
    <link rel="stylesheet" href=
"https://unpkg.com/onsenui/css/onsenui.css">
    <link rel="stylesheet" href=
"https://unpkg.com/onsenui/css/onsen-css-components.min.css">
    <script src=
"https://unpkg.com/onsenui/js/onsenui.min.js">
    </script>
    <style>
        body{
            background-color:lightgreen;
        }
    </style>
</head>
  
<body>
    <center>
        <h2 style="color:green;">
            w3wiki
        </h2>
        <strong>
            Onsen UI CSS Component Segment
        </strong> <br> <br>
  
        <div class="segment" style="width:120px;">
            <div class="segment__item">
                <input type="checkbox" class="segment__input">
                <div class="segment__button">
                    1
                </div>
            </div>
  
            <div class="segment__item">
                <input type="checkbox" class="segment__input">
                <div class="segment__button">
                    2
                </div>
            </div>
            <div class="segment__item">
                <input type="checkbox" class="segment__input">
                <div class="segment__button">
                    3
                </div>
            </div>
            <div class="segment__item">
                <input type="checkbox" class="segment__input">
                <div class="segment__button">
                    4
                </div>
            </div>
        </div>
    </center>
</body>
</html>


Output:      

 

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



Contact Us