Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Bootstrap
  • Tailwind
  • Bulma
  • Foundation
  • Primer
  • Spectre
  • Onsen UI
  • Semantic UI
  • Pure CSS
  • Materialize
  • SASS
  • LESS
  • Blaze UI
  • CSS Frameworks
  • Color Picker
  • CSS
  • CSS Formatter
  • Web Technology
Open In App
Next Article:
Primer CSS Extended Vertical Margins
Next article icon

Primer CSS Extended Spacing Scale

Last Updated : 29 May, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Primer CSS is a free open-source CSS framework built on technologies that provide insights into key design elements like space, typeface, and color. This methodical approach guarantees that the patterns are both consistent and compatible. It's primarily useful and adaptable. It was made with the help of the GitHub design system. Its CSS approach is guided by object-oriented CSS foundations, practical CSS, and BEM design.

Primer CSS Spacing Scale is a specified range of values for specifying the number of utilities such as margin, padding, and so on. Primer CSS uses a base-8 spacing scale, which is highly flexible because it allows us to multiply or divide the eight as many times as we want and still end up with whole integers. 

The Extended Spacing Scale adds six more options to the existing spacing scale. That means the scale which had the range of 0-6 is now increased to 7-12. But this extended range doesn't work for every utility class in every direction. The most effective usage of the extended class is in margin and padding. The extended range i.e., 7-12 doesn't work on the x-axis but does work on the left and right sides individually for margin and padding. But for margin, we cannot use that 7-12 range for the complete x-axis neither together nor individually. Unlike the Basic Scaling Scale in the Extended part, the value increases by 16px instead of 8px.

All the variables and values of the extended spacing scale:

     Variable         Scale          Value    
    $spacer-7        7      48px
    $spacer-8         8      64px
    $spacer-9        9      80px
    $spacer-10      10      96px
    $spacer-11      11               112px
    $spacer-12      12     128px

There are no absolute used classes for this but this is used in various utility classes. 

  • Amount of margin needed: For example, my-5 means 32px of margins will be added on the left and right sides of the container.
  • Amount of padding needed: For example, py-5 means 32px of padding will be added on the top and bottom sides of the container.

Example 1: The example below shows the usage of the extended spacing scale for specifying the padding on the two sides of the container. We have used pt-8 and pl-8 classes which specify the padding to be 64px on the top and left side of the div container.

HTML
<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content=         "width=device-width, initial-scale=1.0">          <link href= "https://unpkg.com/@primer/css@^19.0.0/dist/primer.css"           rel="stylesheet" />     <title>Primer CSS Extended Spacing Scale</title> </head> <body>     <div class="m-4">         <h1 class="color-fg-success"> GeeksforGeeks </h1>         <h3>Primer CSS Extended Spacing Scale</h3>         <br/>      </div>     <div class="pt-8 pl-8 color-bg-open-emphasis                  d-inline-block m-4">         <div class="color-bg-subtle p-1">GeeksforGeeks</div>     </div> </body> </html> 


Output:

 

Example 2: The example below shows the usage of the extended spacing scale for specifying the margin on the two sides of the container. We have used the my-11 class which specifies the padding to be 112px on the top and bottom of the div container. 

HTML
<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content= "width=device-width, initial-scale=1.0">          <link href= "https://unpkg.com/@primer/css@^19.0.0/dist/primer.css"            rel="stylesheet" />     <title>Primer CSS Extended Spacing Scale</title>     <style>        body        {          margin-left:10px;          margin-right:10px;        }     </style> </head>  <body>     <div class="m-4">         <h1 class="color-fg-success"> GeeksforGeeks </h1>         <h3>Primer CSS Extended Spacing Scale</h3>         <br/>      </div>     <div class="my-11 color-bg-open-emphasis                       d-flex flex-column p-4">         <div class="color-bg-subtle p-1">GeeksforGeeks</div>     </div>     <div class="m-4 color-bg-open-emphasis                      d-flex flex-column p-4">         <div class="color-bg-subtle p-1">GeeksforGeeks</div>     </div> </body> </html> 


Output:

 

Reference: https://primer.style/css/support/spacing#spacing-scale


Next Article
Primer CSS Extended Vertical Margins

P

priyanshuchatterjee01
Improve
Article Tags :
  • Web Technologies
  • CSS
  • Primer-CSS
  • Primer-CSS Support

Similar Reads

  • Primer CSS Spacing Scale
    Primer CSS is a free open-source CSS framework based on technologies that provide insights into important style aspects like space, font, and color. This meticulous methodology ensures that its patterns are both stable and compatible. It's mostly practical and adaptable. It was created using the Git
    3 min read
  • 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 ste
    4 min read
  • Primer CSS Em-based Spacing
    Primer CSS Spacing contains Em-based Spacing which is mainly used to provide the spacing between the components, having the values in em, for which the value combined with typography, line height, or the total height becomes sensible numbers. GitHub's body font size is 14px which is difficult to wor
    2 min read
  • Primer CSS Extended Vertical Margins
    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
    2 min read
  • Primer CSS Inline Styles
    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
    2 min read
  • Primer CSS Layout Sidebar Sizing
    Primer CSS is a free and open-source CSS framework that is built using the GitHub design system for providing support to the broad spectrum of GitHub websites. It helps in creating the foundation of the basic style elements such as spacing, components, typography, color, etc. In this article, we wil
    2 min read
  • Primer CSS Extended Negative Margins
    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
    2 min read
  • Primer CSS Typography Line Height Styles
    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
    4 min read
  • Primer CSS Tables
    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
    2 min read
  • Primer CSS Lint Rules (WIP)
    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 the patterns ar
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences