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.
npm install primer-utilitiesVerified import paths — ran on the pinned version, not inferred.
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.
Migrate your project to use the `@primer/css` package instead of `primer-utilities`. This may involve updating import paths and potentially adjusting to newer class names or architectural changes in `@primer/css`.
Consider updating to the actively maintained `@primer/css` package to benefit from ongoing development, bug fixes, and compatibility with modern web standards and tooling.
Always extend or override Primer styles using your own SCSS files that import `primer-utilities` first. Define custom classes with higher specificity or use Sass features like `@extend` if available in your version of Sass.
If encountering compilation issues, try using an older, compatible version of your Sass compiler or consult the `@primer/css` migration guide for an actively supported setup. Alternatively, consider compiling the `build.css` once and linking it directly.
Ensure `node_modules` is included in your Sass compiler's load paths. For example, with Node-Sass or Dart Sass: `sass --load-path=node_modules styles.scss:styles.css`.
Verify that your build process successfully compiles your SCSS (including `@import "primer-utilities/index.scss";`) into a CSS file, and that this compiled CSS file is correctly linked in your HTML's `<head>` section, e.g., `<link rel="stylesheet" href="/path/to/your-compiled-styles.css">`.
Carefully increase the specificity of your custom CSS selectors, or ensure your custom stylesheets are loaded *after* Primer Utilities. For critical overrides, consider using a more specific utility class or modifying the component structure, avoiding `!important` where possible.