Open In App

Primer CSS Components

Primer CSS is a free open-source CSS framework that is built with the GitHub design system to provide support to the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure that 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 a highly reusable model.

Primer CSS Components:



Note: Please refer to the above links or references for understanding the respective component followed by code examples. Some sample examples are given below.

Example 1: The following code demonstrates the use of Primer CSS alert, avatar and blankslate components.






<!DOCTYPE html>
<html>
  
<head>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css"
        rel="stylesheet" />
    <style>
        body {
            margin-left: 20px;
            margin-right: 20px;
        }
    </style>
</head>
  
<body>
    <center>
        <h1 class="color-fg-success"
            GeeksforGeeks 
        </h1>
          
        <h2> Primer CSS</h2>
          
        <h3>Alert component</h3>
        </br>
          
        <div>
            <div class="flash flash-error">
                This is error flash.
            </div>
            <br />
            <div class="flash flash-success">
                This is success flash.
            </div>
        </div>
        <h3> Avatar component</h3>
        </br>
        <div>
            <img class="avatar avatar-7 mr-2" src=
        </div>
        </br>
        <h3> Blankslate component</h3>
        <div>
            <div class="blankslate-action">
                <button class="btn btn-primary" type="button">
                    "OK" action button
                </button>
            </div>
        </div>
    </center>
</body>
  
</html>

Output:

 

Example 2: The following code demonstrates the use of some other Primer CSS components like Breadcrumbs and Branch name.




<!DOCTYPE html>
<html>
  
<head>
    <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>
        <h2> Primer CSS components</h2>
        <h3>Primer CSS Branch Name</h3>
        <a href="#" class="branch-name">
            Master Branch
        </a>
        <a href="#" class="branch-name">
            Sub Branch
        </a>
        </br></br>
        <h3>Primer CSS Breadcrumb</h3>
        <div aria-label="Breadcrumb">
            <ol>
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">GFG tutorials</a>
                </li>
                <li class="breadcrumb-item breadcrumb-item-selected">
                    <a href="#" aria-current="page">Articles</a>
                </li>
            </ol>
        </div>
    </center>
</body>
  
</html>

Output:

 

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


Article Tags :