Primer CSS Utilities

5.0.0 · abandoned · verified Tue Apr 21

primer-utilities provides a collection of immutable, atomic CSS utility classes, designed to facilitate rapid UI development. It forms a foundational part of the Primer Design System, originally developed by GitHub to style its own interfaces. The package's philosophy emphasizes single-purpose classes to promote consistency and reduce custom CSS. The current stable version is 5.0.0, published in January 2019. This standalone package is now superseded by modules within the @primer/css monorepo, which represents the actively maintained version of Primer. While primer-utilities@5.0.0 remains available on npm, it is no longer actively developed or directly maintained as a separate entity.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import Primer Utilities via Sass and apply basic spacing, display, and typography classes to an HTML element. The compiled CSS needs to be linked in the HTML.

/* styles.scss */
@import "primer-utilities/index.scss";

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.5;
}

.my-component {
  background-color: var(--color-bg-default);
  border: var(--border-width-thin) solid var(--color-border-default);
  border-radius: var(--border-radius-2);
}

// To compile:
// npx sass styles.scss:styles.css

<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Primer Utilities Quickstart</title>
    <link rel="stylesheet" href="./styles.css">
</head>
<body>
    <div class="my-component p-4 m-3 d-flex flex-justify-center flex-items-center">
        <h1 class="f4 color-fg-default">Hello, Primer Utilities!</h1>
    </div>
    <p class="text-center mt-6">This demonstrates basic Primer Utilities usage.</p>
</body>
</html>

view raw JSON →