Introduction to Primer CSS

· 1 min read· Your Name
Introduction to Primer CSS

Primer is GitHub’s design system and CSS framework. It provides a set of guidelines and components to create consistent, accessible interfaces.

What is Primer?

Primer is built around three core pillars:

  1. Primitives - Design tokens for colors, spacing, and typography
  2. CSS - Utility classes and component styles
  3. Components - React and ViewComponent implementations

Getting Started

Install Primer CSS via npm:

npm install @primer/css

Import the CSS in your project:

@import "@primer/css/index.scss";

Utility Classes

Primer provides a comprehensive set of utility classes:

Colors

<p class="color-fg-default">Default text color</p>
<p class="color-fg-muted">Muted text color</p>
<p class="color-fg-accent">Accent text color</p>

Spacing

<div class="p-3">Padding of 16px</div>
<div class="m-4">Margin of 24px</div>

Flexbox

<div class="d-flex flex-items-center flex-justify-between">
  <span>Left</span>
  <span>Right</span>
</div>

Components

Primer includes many pre-built components:

ComponentDescription
BoxContainer with border and padding
ButtonInteractive button styles
LabelTags and badges
HeaderNavigation header

Dark Mode

Primer supports dark mode through data attributes:

<html data-color-mode="auto" data-light-theme="light" data-dark-theme="dark">

Resources

Start building with Primer today!

Related Posts