Open In App

Primer CSS Spacing

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 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 Spacing can be utilized to provide the indentation around the element by implementing the defined classes i.e. it is used to provide the spacing within the components such as buttons, form elements, etc. It is primarily used to achieve a bigger vertical as well as horizontal spacing between the sections.



Primer CSS Spacing Components:

Syntax:



<div class="Primer-CSS-SpacingClasses">
   ...
</div>

We can provide spacing around the element in 2 ways, i.e. by using the padding & margin that will create space around the elements. 

Please refer to the Primer CSS Padding & Primer CSS Margin articles for a detailed description.

Example 1: This example describes the Primer CSS Spacing by demonstrating the uniform padding utilities using the required classes in it.




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0" />
    <title>Primer CSS Spacing</title>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css" 
          rel="stylesheet" />
</head>
  
<body>
    <center>
        <h1 class="color-fg-open">
              GeeksforGeeks
          </h1>
        <h3>Primer CSS Spacing</h3
    </center
    <strong>p-0:</strong>
        <div class="p-0 color-bg-success">
            GeeksforGeeks 
        </div
    <strong>p-1:</strong>
        <div class="p-1 color-bg-success">
            GeeksforGeeks 
        </div
    <strong>p-2:</strong>
        <div class="p-2 color-bg-success">
            GeeksforGeeks 
        </div
    <strong>p-3:</strong>
        <div class="p-3 color-bg-success">
            GeeksforGeeks 
        </div
    <strong>p-4:</strong>
        <div class="p-4 color-bg-success">
            GeeksforGeeks 
        </div
    <strong>p-5:</strong>
        <div class="p-5 color-bg-success">
            GeeksforGeeks 
        </div
    <strong>p-6:</strong>
        <div class="p-6 color-bg-success">
            GeeksforGeeks 
        </div>
</body>
</html>

Output:

 

Example 2: This example describes the Primer CSS Spacing by demonstrating the uniform margin utilities using the required classes in it.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0" />
    <title>Primer CSS Spacing</title>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css" 
          rel="stylesheet" />
</head>
  
<body>
    <div class="m-4">
        <h1 class="color-fg-success">
            GeeksforGeeks
        </h1>
        <h2>Primer CSS Spacing</h2
    </div>
    <div class="d-flex flex-items-baseline flex-justify-around">
        <div class="color-bg-success">
            <div class="m-0 p-1 color-bg-success-emphasis">
                .m-0 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-1 p-1 color-bg-success-emphasis">
                .m-1 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-2 p-1 color-bg-success-emphasis">
                .m-2 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-3 p-1 color-bg-success-emphasis">
                .m-3 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-4 p-1 color-bg-success-emphasis">
                .m-4 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-5 p-1 color-bg-success-emphasis">
                .m-5 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-6 p-1 color-bg-success-emphasis">
                .m-6 
            </div>
        </div>
    </div>
</body>
</html>

Output: 

 

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


Article Tags :