Open In App

Primer CSS Labels Counters

Last Updated : 28 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Primer CSS offers a Counter component that is used to attach the count to the navigational elements or buttons. Generally, the counter has three forms i.e Counter, Counter–primary, and Counter–secondary. Note that the visibility of the counter is hidden when it is empty.

Primer CSS Counters:

  • Counter: This class is used to define a counter component in labels. 
  • Counter–primary: This class is used to define the counter component that has a stronger background color.
  • Counter–secondary: This class is used to define the counter component that has a more subtle text color.

Syntax:

<span class="Counter mr-1 Counter--primary">
    ...
</span>

Example 1: Below example demonstrates the use of Primer CSS Counters.

HTML




<!DOCTYPE html>
<html>
<head>
    <title> Primer CSS Counters Labels </title>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css" 
    rel="stylesheet" />
</head>
  
<body>
  <center>
    <h1 class="color-fg-success"> GeeksforGeeks </h1>
    <h3> Primer CSS Counters Labels </h3>
  
    <span class="Counter mr-1 mt-3">
        77
    </span>
    <span class="Counter mr-1 mt-3 Counter--primary">
        88
    </span>
    <span class="Counter mr-1 mt-3 Counter--secondary">
        66
    </span>
  </center>
</body>
</html>


Output:

Primer CSS Counters

Example 2: Below example demonstrates the use of Primer CSS Counters on tabs.

HTML




<!DOCTYPE html>
<html>
<head>
    <title> Primer CSS Counters Labels </title>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css" 
    rel="stylesheet" />
</head>
  
<body style="width: 650px">
  <center>
    <h1 class="color-fg-success"> GeeksforGeeks </h1>
    <h3> Primer CSS Counters Labels </h3>
    <div class="tabnav">
      <nav class="tabnav-tabs" aria-label="Foo bar">
        <a href="#" class="tabnav-tab" aria-current="page">
            Tutorials 
            <span class="Counter">12</span>
        </a>
        <a href="#" class="tabnav-tab">Jobs</a>
      </nav>
    </div>
  </center>
</body>
</html>


Output:

Primer CSS Counters

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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads