Open In App

Primer CSS Variables

Primer CSS is a free open-source CSS framework built with the GitHub design system to support the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method ensures our patterns are steady and interoperable with every other. Object-oriented CSS principles, functional CSS, and BEM architecture influence its approach to CSS. It is a highly reusable model.

Primer CSS variables are a way to store information that you can reuse later. In that case, the work will be easy and there is no need to define the CSS property repeatedly.



The typographical variables that are used in the Primer CSS are listed below:

Layout Variables:



Misc Variable:

Other Variable:

Example 1: In the above code, we will make use of the above variables to demonstrate the use of variables.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^16.0.0/dist/primer.css" />
    <link rel="stylesheet" href="style.css">
</head>
  
<body style="margin:115px;">
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
        <div class="gfg">
            <h3>A computer science portal for geeks</h3>
        </div>
    </center>
</body>
  
</html>

SCSS code:

$border-width: 2px solid green;
.gfg {
   border:$border-width;
}

Compiled CSS Code:

.gfg {
   border: 2px solid green;
}

Output:

 

Example 2: In the above code, we will make use of the above variables to demonstrate the use of variables.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^16.0.0/dist/primer.css" />
    <link rel="stylesheet" href="style.css">
</head>
  
<body style="margin:115px;">
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
  
        <h3>A computer science portal for geeks</h3>
    </center>
</body>
  
</html>

SCSS Code:

$h0-size: 40px;
h3{
   font-size:$h0-size;
}

Compiled CSS Code:

h3 {
     font-size: 40px;
}

Output:

 

Reference: https://primer.style/css/support/variables


Article Tags :