Open In App

Primer CSS Labels Elements

Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, and BEM architecture. It is highly reusable and flexible. It is created with GitHub’s design system.

In this article, we will learn various Primer CSS Labels Elements. Primer CSS offers Labels that provide some metadata to the user or indicates the status of an item. There are 3 types of labels, Labels to indicate metadata, States to show the status, and Counters to indicate the count of a number of items. 



Primer CSS Labels elements:

Note: Please refer to the links of Primer CSS Labels elements mentioned above for the respective type of Label element followed by the codes for better understanding. A few sample programs are given below.



Syntax:

 <span class="<label-element-classes> ...">
       ....
 </span>  

Example 1:  The following code demonstrates the issue labels and diffstat labels.




<!DOCTYPE html>
<html>
  
<head>
    <meta name="viewport" content=
          "width= device-width, initial-scale = 1">
  
    <link rel="stylesheet" href=
  
</head>
<style>
    body{
        background-color:lightgrey;
        text-align:center;
    }
    span{
        background-color:lightblue;
    }
</style>
  
<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
      
    <h3>Primer CSS Issue Label</h3>
    <span class="IssueLabel color-bg-accent-emphasis 
                 color-fg-on-emphasis mr-2">
         GeeksforGeeks
         <svg width="16" height="16" fill="currentColor" 
                class="bi bi-laptop" viewBox="0 0 16 16">
                <path d="M13.5 3a.5.5 0 0 1 .5.5V11H2V3.5a.5.5 
            0 0 1 .5-.5h11zm-11-1A1.5 1.5 0 0 0 1 
            3.5V12h14V3.5A1.5 1.5 0 0 0 13.5 2h-11zM0 12.5h16a1.5 
            1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 0 12.5z"/>
        </svg>
    </span>
    <span class="IssueLabel color-bg-danger-emphasis 
                 color-fg-on-emphasis mr-2">
        Practice and Remarks
    </span><br><br>
    <h3>Primer CSS Diffstat</h3>
    <span class="diffstat tooltipped tooltipped-w" 
          aria-label="10 changes: 7 additions, 3 deletions">10
        <span class="diffstat-block-added"></span>
        <span class="diffstat-block-deleted"></span>              
        <span class="diffstat-block-neutral"></span>
    </span>        
</body>
</html>

Output:

 

Example 2: The following code demonstrates the counter and state labels.




<!DOCTYPE html>
<html>
  
<head>
    <meta name="viewport" content=
          "width= device-width, initial-scale = 1">
  
    <link rel="stylesheet" href=
  
</head>
<style>
    body{
        background-color:lightgrey;
        text-align:center;
    }
    span{
        background-color:lightblue;
    }
</style>
  
<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
      
    <h3> Primer CSS Counters Labels </h3>  
    <span class="Counter mr-1 mt-3 Counter--primary">
        99
    </span>
    <a href="#" class="tabnav-tab" aria-current="page">
            Tutorials 
        <span class="Counter">
            66
        </span>
    </a>
    <br><br>
    <h3>Primer CSS States</h3>
    
    <span class="State State--draft mr-2 mt-3">
        Default State
    </span>  
    <span class="State State--open mr-2 mt-3">
        Open State
    </span>  
    <span class="State State--merged mr-2 mt-3">
        Merged State
    </span>  
    <span class="State State--closed mr-2 mt-3">
        Close State
    </span>    
</body>
</html>

Output:

 

Reference: https://primer.style/css/components/labels


Article Tags :