{"id":15477,"library":"primer-utilities","title":"Primer CSS Utilities","description":"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.","status":"abandoned","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/primer/primer/tree/master/modules/primer-utilities","tags":["javascript","primer","css","github","design-system"],"install":[{"cmd":"npm install primer-utilities","lang":"bash","label":"npm"},{"cmd":"yarn add primer-utilities","lang":"bash","label":"yarn"},{"cmd":"pnpm add primer-utilities","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides foundational variables and mixins required for Primer Utilities' Sass compilation.","package":"primer-support","optional":false}],"imports":[{"note":"This is the primary way to import all utilities when using a Sass/SCSS preprocessor. Ensure your Sass compiler's include paths are configured to find `node_modules`.","symbol":"index.scss","correct":"@import \"primer-utilities/index.scss\";"},{"note":"For direct browser usage, link to the pre-compiled CSS file. The `build.css` is included in the npm package.","symbol":"CSS File","correct":"<link rel=\"stylesheet\" href=\"/path/to/node_modules/primer-utilities/build/build.css\">"},{"note":"You can import individual utility partials from the `/lib/` folder if you only need a subset of the utilities, reducing bundle size.","symbol":"Specific Partial","correct":"@import \"primer-utilities/lib/align\";"}],"quickstart":{"code":"/* styles.scss */\n@import \"primer-utilities/index.scss\";\n\nbody {\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n  line-height: 1.5;\n}\n\n.my-component {\n  background-color: var(--color-bg-default);\n  border: var(--border-width-thin) solid var(--color-border-default);\n  border-radius: var(--border-radius-2);\n}\n\n// To compile:\n// npx sass styles.scss:styles.css\n\n<!-- index.html -->\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Primer Utilities Quickstart</title>\n    <link rel=\"stylesheet\" href=\"./styles.css\">\n</head>\n<body>\n    <div class=\"my-component p-4 m-3 d-flex flex-justify-center flex-items-center\">\n        <h1 class=\"f4 color-fg-default\">Hello, Primer Utilities!</h1>\n    </div>\n    <p class=\"text-center mt-6\">This demonstrates basic Primer Utilities usage.</p>\n</body>\n</html>","lang":"scss","description":"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."},"warnings":[{"fix":"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`.","message":"The `primer-utilities` npm package is officially deprecated. Its code and active development have been migrated into the larger `@primer/css` monorepo. Developers should transition to using `@primer/css` for active maintenance, updates, and new features.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Consider updating to the actively maintained `@primer/css` package to benefit from ongoing development, bug fixes, and compatibility with modern web standards and tooling.","message":"The standalone `primer-utilities` package has not received updates since version 5.0.0, published in January 2019. It is considered unmaintained, and relying on it for new projects or expecting bug fixes is not advisable.","severity":"deprecated","affected_versions":"5.0.0"},{"fix":"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.","message":"Direct manipulation of `primer-utilities` SCSS files or variables (e.g., overriding in `node_modules`) is highly discouraged. Such modifications are fragile and will break during updates or when migrating to the `@primer/css` monorepo structure.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"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.","message":"Due to its age, `primer-utilities@5.0.0` might exhibit compatibility issues with very recent versions of Sass compilers (e.g., Dart Sass) or modern PostCSS plugins, potentially leading to compilation errors or unexpected output.","severity":"gotcha","affected_versions":"5.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"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`.","cause":"The Sass compiler cannot locate the `primer-utilities` package within `node_modules` or the specified include paths.","error":"Error: Can't find stylesheet to import. @import \"primer-utilities/index.scss\";"},{"fix":"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\">`.","cause":"The compiled CSS for Primer Utilities is not being loaded or correctly linked in your HTML document.","error":"Primer utility classes (e.g., `m-4`, `p-responsive`) are not applying any styles in the browser."},{"fix":"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.","cause":"Specificity conflict where Primer's utility classes have a higher CSS specificity or appear later in the cascade than your custom styles.","error":"My custom CSS is being overridden by Primer utility classes, even with supposedly higher specificity."}],"ecosystem":"npm"}