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
  • CSS Tutorial
  • CSS Exercises
  • CSS Interview Questions
  • CSS Selectors
  • CSS Properties
  • CSS Functions
  • CSS Examples
  • CSS Cheat Sheet
  • CSS Templates
  • CSS Frameworks
  • Bootstrap
  • Tailwind
  • CSS Formatter
Open In App
Next Article:
Primer CSS States
Next article icon

Primer CSS Utilities

Last Updated : 15 Nov, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Primer CSS Utilities gives the structure blocks to design and deal with a reach of normal use cases that assist us with trying not to compose custom styles. At the point when we really want to add some edge or cushioning, instead of adding another selector intended for that utilization case, we can utilize utilities. This assists us with diminishing the number of novel property-estimation coordinates and assists us with keeping more reliable styles across the site.

Primer CSS Utilities:

  • Animations: Animations are the most common things on the web. Animations in sense of motions that can be used on buttons, forms, or any other components. So Primer CSS Provides us with animation classes that you can use to emphasize an element.
  • Borders: Primer CSS Borders is a utility class that applies borders to a div container of HTML by simply applying the provided class. We can even customize the border’s style.
  • Box shadow: Primer CSS Box shadow applies shadow to a box container. It helps to make the content elevated so that the user pays attention to the content inside the container box. In Primer CSS, we can add different types of box shadows – small, medium, large, and extra-large.
  • Colors: Primer color utility classes to set the color of the text, background, and border.
  • Details:Primer CSS Details Classes are made in order to improve the behavior of the default HTML Details component.
  • Flexbox: Primer CSS is much more responsive and mobile-friendly. It is easy to position child elements and the main container.
  • Grid: The Grid contains 12 columns and is percentage-based. The responsive layouts can be designed with a number of columns a container spans that can be adjusted across breakpoints.
  • Layout: Primer CSS Layout is used to change the document layout with the help of classes that provide inline, block, table, etc. which can customize the document.
  • Margin: Primer CSS Margin allows the users to reduce the amount of custom CSS that shares the same properties and allows them to achieve many different page layouts using the same styles.
  • Padding: Padding is used to create space around the element, inside any defined border. We can set different padding for individual sides(top, right, bottom, left). It is important to add border properties to implement padding properties.
  • Typography: Typography utilities in Primer CSS are designed so that it works in combination with line-height utilities to make them much more sensible and useful to use. Typography utilities also exist as variables that we can use in components or Custom CSS.

Note: There are 11 utilities in Primer CSS all of them have individual articles for understanding, how to use them and where to use them.

Below examples illustrates Primer CSS Utilities:

Example 1: In this example, we will use the Primer CSS Animation utility.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title> Primer CSS Animations </title>
    <link rel="stylesheet" 
             href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" />
</head>
  
<body>
    <div class="text-center">
        <h1 class="color-fg-success"> GeeksforGeeks </h1>
        <strong>Primer CSS Animations Utility</strong>
    </div>
    <div class="m-2 p-2 Box">
        <!--Animation Utility Used -->
        <span class="anim-fade-in">
        <svg width="12"
            height="16"
            viewBox="0 0 12 16"
            class="octicon octicon-check"
            aria-hidden="true">
            <path fill-rule="evenodd"
                d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z" />
        </svg>
        </span>
        <span class="content p-2">Primer CSS Fade In Animation</span>
        <!--Animation Utility Used -->
        <span class="anim-fade-out">
        <svg width="12"
            height="16"
            viewBox="0 0 12 16"
            class="octicon octicon-check"
            aria-hidden="true">
            <path fill-rule="evenodd"
                d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z" />
        </svg>
        </span>
        <span class="content p-2">Primer CSS Fade Out Animation</span>
        <!--Animation Utility Used -->
        <span class="anim-fade-up">
        <svg width="12"
            height="16"
            viewBox="0 0 12 16"
            class="octicon octicon-check"
            aria-hidden="true">
            <path fill-rule="evenodd"
                d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z" />
        </svg>
        </span>
        <span class="content p-2">Primer CSS Fade Up Animation</span>
    </div>
</body>
</html>
 
 

Output:

Primer CSS Animation Utility

Example 2: In this example, we will use the Primer CSS Details utility.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,
                initial-scale=1.0">
    <!-- Primer CSS CDN Link-->
    <link rel="stylesheet" 
             href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" />
    <title>Primer CSS Details Utility</title>
</head>
  
<body>
    <h1 style="color: green;">GeeksforGeeks</h1>
    <h3>Primer CSS Details Utility</h3>
    <div class="m-2">
        <!--Detail Utility Used -->
        <details class="details-overlay details-overlay-dark">
            <summary class="btn btn-primary"> Click Me</summary>
            <div class="border p-3 mt-2">
                This is the sample text that will be
                shown when the "Click Me" text is clicked.
            </div>
        </details>
    </div>
</body>
  
</html>
 
 

Output:

Primer CSS Detail Utility

Note: For more examples of other utilities you can visit those individual articles.

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



Next Article
Primer CSS States

N

narendrapekbcf
Improve
Article Tags :
  • CSS
  • Web Technologies

Similar Reads

  • Primer CSS Heading Utilities
    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 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 States
    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 Typographic Utilities
    Primer CSS is a free open-source CSS framework based on principles that lay the groundwork for basic design components including spacing, font, and color. This strategy ensures that our patterns are consistent and compatible with one another. Object-Oriented CSS principles, functional CSS, and BEM a
    4 min read
  • Primer CSS Toasts
    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
    3 min read
  • Primer CSS Body Content Utilities
    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 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
    10 min read
  • Primer CSS Link and Color Utilities
    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 Theming
    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 colour. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
    3 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