Milligram vs Primer

In the world of web development, CSS frameworks are invaluable tools that help developers create responsive and aesthetically pleasing websites efficiently. Among the myriad of frameworks available, Milligram and Primer stand out for their unique features and use cases. This article provides a comprehensive comparison of these two frameworks, covering everything from their design philosophies to their implementation details.

Milligram: A Minimalist’s Delight

Milligram is a minimalist CSS framework designed for better performance and higher productivity with fewer properties to reset. It’s perfect for projects that require a lightweight framework without the need for extensive customization.

Key Features of Milligram

  • Size: Milligram is exceptionally small, with a gzipped size of only ~2KB.
  • Responsive Grid: Utilizes a simple grid system based on Flexbox for easy alignment and distribution of elements.
  • Typography: Provides styles for typography, buttons, forms, and lists.
  • Utilities: Comes with a set of utilities for commonly used CSS tasks.


Milligram can be easily included in your project via npm, yarn, Bower, or a CDN. Here are the links to their installation pages:


The Milligram documentation is straightforward and easy to follow, providing clear examples and usage instructions.

Third-Party Addons or Libraries

While Milligram is designed to be minimal, there are a few third-party addons that can extend its capabilities:

  • Milligram-scss: An SCSS version of Milligram for those who prefer using a preprocessor.
  • Milligram-themes: A collection of themes for Milligram to quickly change the look and feel of your project.

Code Sample

Here’s a simple example of a responsive grid layout using Milligram:

<!DOCTYPE html>
  <link rel="stylesheet" href="[email protected]/dist/milligram.min.css">

<div class="container">
  <div class="row">
    <div class="column column-50 column-offset-25">
      <h1>Centered Column</h1>
      <p>This is a centered column using Milligram's grid system.</p>


Primer: GitHub’s Own CSS Toolkit

Primer is the CSS framework developed by GitHub for its own use before being made available to the public. It is designed to be highly scalable and modular, making it a great choice for large projects and design systems.

Key Features of Primer

  • Modularity: Primer is built with a modular approach, allowing developers to include only the parts they need.
  • Responsive Design: It includes a responsive grid system and utilities for a mobile-first approach.
  • Components: Offers a wide range of pre-styled components like navigation, alerts, and tooltips.
  • Utilities: Provides utility classes for spacing, typography, and more to help customize components without writing custom CSS.


Primer can be installed via npm or included directly from a CDN. Here are the links for installation:


The comprehensive Primer documentation provides detailed guidelines on using the framework, including examples and explanations of the various components and utilities.

Third-Party Addons or Libraries

Primer is designed to be used as is, and due to its modular nature, there isn’t a wide range of third-party addons. However, GitHub provides several related projects:

  • Octicons: GitHub’s icon set, used in conjunction with Primer.
  • Primer Components: React components that complement the Primer CSS framework.

Code Sample

Below is an example of using Primer to create a simple navigation bar:

<!DOCTYPE html>
  <link rel="stylesheet" href="">

<nav class="UnderlineNav" aria-label="Foo bar">
  <div class="UnderlineNav-body">
    <a href="#home" class="UnderlineNav-item selected" aria-current="page">Home</a>
    <a href="#documentation" class="UnderlineNav-item">Documentation</a>
    <a href="#about" class="UnderlineNav-item">About</a>


This example demonstrates the use of Primer’s navigation component with the UnderlineNav class to create a simple, styled navigation bar. The selected class is used to indicate the current active page.

In the next section, we will delve into the comparison of customization options, community support, and real-world usage scenarios for both Milligram and Primer. We will also explore advanced implementation techniques and provide more code samples to illustrate the versatility of these frameworks. Stay tuned for the continuation of this in-depth comparison.

Customization Options

Both Milligram and Primer offer customization options, but their approaches differ significantly due to their underlying design philosophies.

Milligram Customization

Milligram’s minimalistic approach means it doesn’t offer a built-in customization system like a theme builder or custom CSS variables. However, developers can override the default styles by writing additional CSS. Since Milligram is minimal by design, it doesn’t take much effort to customize it to fit your design needs.

For those who prefer using a CSS preprocessor, customizing Milligram is more convenient with the SCSS version. You can overwrite the SCSS variables before compilation to tailor the framework to your project’s requirements.

Primer Customization

Primer, on the other hand, is built with customization in mind. It uses SCSS variables extensively, making it easy to change colors, spacing, typography, and more. Primer’s modular nature means you can import only the styles you need and customize them without loading unnecessary CSS.

GitHub has designed Primer to be part of a larger design system, so it’s prepared to be adapted to a variety of design languages and needs.

Community Support and Resources

The community support for a CSS framework can be a crucial factor in its adoption, as it influences the availability of resources, extensions, and timely updates.

Milligram Community

Milligram, being a smaller and more focused framework, has a smaller community. There are fewer community-generated resources, but the simplicity of the framework makes it easy to get started without much external help. The GitHub repository is the primary place for support and discussions.

Primer Community

Primer benefits from being created by GitHub and is used extensively in GitHub’s own projects, which means it has a strong backing and a larger community. It has more community resources, including plugins, tools, and extensive documentation. The Primer GitHub repository is active, with many contributors and frequent updates.

Real-World Usage Scenarios

When choosing between Milligram and Primer, consider the scale and nature of your project.

When to Use Milligram

Milligram is best suited for small to medium-sized projects that require a lightweight, fast-loading framework. It’s ideal for developers who want to start with a clean slate and apply their own styling without battling against heavy-handed default styles.

When to Use Primer

Primer is well-suited for larger projects, especially when building complex web applications or design systems that require a scalable and modular framework. It’s also a good choice if you want to adhere to the design principles and components that have been tested and refined by GitHub.

Advanced Implementation Techniques

Both frameworks allow for advanced implementation techniques to further enhance your project.

Advanced with Milligram

While Milligram itself is simple, you can combine it with preprocessors like SCSS or PostCSS to create a more sophisticated workflow. You can also integrate it with JavaScript frameworks like Vue.js or React to manage dynamic styles.

Advanced with Primer

Primer is designed to work well with advanced front-end development tools and workflows. You can use it with component-based frameworks like React, and it even has its own set of React components. Using Primer within a build system like Webpack is straightforward, allowing for advanced customization and optimization.

Code Samples Continued

Let’s look at more advanced code samples for each framework.

Milligram Advanced Sample

Here’s an example of customizing Milligram using SCSS:

// Custom variables
$font-family: 'Roboto', sans-serif;
$primary-color: #3498db;

// Import Milligram SCSS
@import "milligram";

// Additional styles
body {
  font-family: $font-family;
  color: $primary-color;

Primer Advanced Sample

Creating a custom button with Primer using SCSS might look like this:

// Import Primer core variables
@import "@primer/css/support/variables";

// Custom button styles
.btn-custom {
  @include btn;
  background-color: $blue-500;
  border-color: darken($blue-500, 5%);
  &:hover {
    background-color: darken($blue-500, 5%);


Choosing between Milligram and Primer ultimately depends on the specific needs of your project. Milligram is excellent for those who prefer a minimalist, straightforward approach and are building smaller, performance-focused sites. On the other hand, Primer is ideal for developers working on large-scale applications or who require a framework with a robust design system and the ability to customize extensively.

Both frameworks have their strengths and can be the right choice in the right context. By understanding their differences and evaluating your project’s requirements, you can make an informed decision on which framework to adopt. Whether you choose the simplicity of Milligram or the comprehensive nature of Primer, both frameworks offer the tools you need to build modern, responsive websites.

Remember to explore the documentation and community resources for both Milligram and Primer to fully leverage their capabilities and keep your development process efficient and effective.

More Milligram CSS Comparisons


What do you think?