Top Related Projects
A utility-first CSS framework for rapid UI development.
Modern CSS framework based on Flexbox
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
The instant on-demand atomic CSS engine.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Quick Overview
Primer CSS is GitHub's design system and CSS framework. It provides a comprehensive set of reusable components and utility classes to build consistent and responsive web interfaces. Primer CSS is the foundation for GitHub's own user interface and is designed to be flexible and customizable.
Pros
- Extensive set of pre-built components and utility classes
- Consistent with GitHub's design language
- Well-documented and regularly maintained
- Accessible and responsive by default
Cons
- Learning curve for developers not familiar with utility-first CSS
- May require additional configuration for projects with different design requirements
- Large file size if using the entire framework
- Tightly coupled with GitHub's design aesthetic, which may not fit all projects
Code Examples
- Using Primer's button styles:
<button class="btn btn-primary">Primary Button</button>
<button class="btn btn-outline">Outline Button</button>
- Creating a simple layout with Primer's grid system:
<div class="container-lg clearfix">
<div class="col-4 float-left p-2">
<div class="Box">Sidebar content</div>
</div>
<div class="col-8 float-left p-2">
<div class="Box">Main content</div>
</div>
</div>
- Applying utility classes for spacing and typography:
<div class="p-4 mb-3 bg-gray">
<h2 class="h1-mktg text-center mb-2">Large Marketing Heading</h2>
<p class="text-center text-gray-light">Subtext with lighter color</p>
</div>
Getting Started
To use Primer CSS in your project, you can include it via CDN or install it using npm:
- Via CDN:
<link rel="stylesheet" href="https://unpkg.com/@primer/css/dist/primer.css" />
- Via npm:
npm install @primer/css
Then import it in your JavaScript file:
import '@primer/css/index.scss'
Or in your SCSS file:
@import "@primer/css/index.scss";
After including Primer CSS, you can start using its classes and components in your HTML markup.
Competitor Comparisons
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Highly customizable with a utility-first approach
- Faster development process with pre-built classes
- Smaller file sizes due to purging unused styles
Cons of Tailwind CSS
- Steeper learning curve for developers new to utility-first CSS
- Can lead to longer class names and potentially cluttered HTML
- Less semantic markup compared to traditional CSS approaches
Code Comparison
Tailwind CSS:
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Button
</button>
Primer CSS:
<button class="btn btn-primary">
Button
</button>
Additional Notes
Tailwind CSS offers a more granular approach to styling, allowing for greater flexibility but potentially sacrificing readability. Primer CSS, being a more traditional CSS framework, provides a simpler syntax and more semantic class names, but may be less customizable out of the box.
Both frameworks have their strengths and are suitable for different project types and team preferences. Tailwind CSS excels in rapid prototyping and custom designs, while Primer CSS is well-suited for projects that align with GitHub's design system or prefer a more traditional CSS approach.
Modern CSS framework based on Flexbox
Pros of Bulma
- More comprehensive component library with a wider range of pre-built elements
- Flexbox-based grid system for easier responsive layouts
- Modular architecture allowing for customization and smaller file sizes
Cons of Bulma
- Less frequent updates and maintenance compared to Primer
- Not as tightly integrated with a specific design system or ecosystem
- Steeper learning curve for developers new to the framework
Code Comparison
Bulma button:
<button class="button is-primary is-large">
Large button
</button>
Primer button:
<button class="btn btn-primary btn-large">
Large button
</button>
Both frameworks offer similar syntax for creating buttons, with slight differences in class naming conventions. Bulma uses the is-
prefix for modifiers, while Primer uses separate classes for each property.
Bulma and Primer are both popular CSS frameworks, each with its own strengths. Bulma offers a more extensive component library and a flexible grid system, making it suitable for a wide range of projects. Primer, being GitHub's design system, is more focused and integrated with their ecosystem. The choice between the two depends on project requirements, team familiarity, and desired level of customization.
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
Pros of Bootstrap
- More comprehensive and feature-rich, offering a wider range of components and utilities
- Larger community and ecosystem, resulting in more third-party themes and plugins
- Better-known brand with extensive documentation and resources
Cons of Bootstrap
- Heavier file size, potentially impacting page load times
- More opinionated design, which may require more customization to achieve unique looks
- Steeper learning curve due to its extensive feature set
Code Comparison
Bootstrap:
<div class="container">
<div class="row">
<div class="col-md-4">Column 1</div>
<div class="col-md-4">Column 2</div>
<div class="col-md-4">Column 3</div>
</div>
</div>
Primer:
<div class="container-lg">
<div class="d-flex flex-justify-between">
<div class="col-4">Column 1</div>
<div class="col-4">Column 2</div>
<div class="col-4">Column 3</div>
</div>
</div>
Both frameworks offer grid systems, but Bootstrap uses a more traditional row-column approach, while Primer leverages flexbox for layout control. Primer's syntax is often more concise, focusing on utility classes, whereas Bootstrap provides more specific class names for various components and layouts.
The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
Pros of Foundation
- More comprehensive framework with additional JavaScript components
- Extensive customization options through Sass variables
- Robust grid system with flexible layout options
Cons of Foundation
- Steeper learning curve due to more complex structure
- Larger file size, potentially impacting page load times
- Less frequent updates compared to Primer
Code Comparison
Foundation:
.button {
@include button-base;
@include button-size;
@include button-style;
}
Primer:
.btn {
@include btn-base;
@include btn-solid($bg: $btn-bg, $fg: $btn-text);
}
Both frameworks use mixins for button styling, but Foundation's approach is more modular, separating base, size, and style into distinct mixins. Primer combines these aspects into fewer mixins, potentially offering a simpler implementation at the cost of some flexibility.
Foundation's grid system is more complex but offers greater control:
.grid-x {
display: flex;
flex-flow: row wrap;
}
Primer's grid system is simpler and more straightforward:
.container-lg {
max-width: $container-lg;
margin-right: auto;
margin-left: auto;
}
This comparison highlights Foundation's more extensive features and customization options, while Primer focuses on simplicity and ease of use.
The instant on-demand atomic CSS engine.
Pros of UnoCSS
- Highly customizable and extensible with a powerful preset system
- Extremely fast performance due to its on-demand atomic CSS engine
- Smaller bundle size with zero-runtime overhead
Cons of UnoCSS
- Steeper learning curve for developers used to traditional CSS frameworks
- Less opinionated, requiring more setup and configuration
- Smaller community and ecosystem compared to more established frameworks
Code Comparison
UnoCSS:
<div class="text-center py-4 px-8 bg-gray-100 rounded-lg shadow-md">
<h1 class="text-2xl font-bold text-gray-800">Hello, UnoCSS!</h1>
</div>
Primer CSS:
<div class="Box p-4 text-center">
<h1 class="h2-mktg">Hello, Primer CSS!</h1>
</div>
Summary
UnoCSS offers greater flexibility and performance but requires more setup. Primer CSS provides a more opinionated and ready-to-use solution with a larger ecosystem. The choice between them depends on project requirements and team preferences.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Pros of styled-components
- Component-based styling with CSS-in-JS approach
- Dynamic styling based on props
- Automatic critical CSS extraction
Cons of styled-components
- Steeper learning curve for developers new to CSS-in-JS
- Potential performance overhead for large applications
- Less suitable for projects requiring a traditional CSS approach
Code Comparison
styled-components:
const Button = styled.button`
background-color: ${props => props.primary ? 'blue' : 'white'};
color: ${props => props.primary ? 'white' : 'blue'};
padding: 10px 20px;
border: 2px solid blue;
`;
css:
.Button {
background-color: white;
color: blue;
padding: 10px 20px;
border: 2px solid blue;
}
.Button--primary {
background-color: blue;
color: white;
}
styled-components offers a more dynamic and component-centric approach to styling, while css provides a traditional, separation-of-concerns method. The choice between the two depends on project requirements, team preferences, and scalability needs.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Primer CSS
The CSS implementation of GitHub's Primer Design System
Documentation
:warning: The documentation of this repo is not maintained anymore. Please raise any documentation-specific pull requests in primer.style/design
Our documentation site lives at primer.style/css. You'll be able to find detailed documentation on getting started, all of the components, our theme, our principles, and more.
Install
This repository is distributed with npm. After installing npm, you can install @primer/css
with this command:
npm install --save @primer/css
Usage
The included source files are written in Sass using SCSS syntax. After installing with npm, you can add your project's node_modules
directory to your Sass include paths (AKA load paths in Ruby), then import it like this:
@import "@primer/css/index.scss";
You can import individual Primer modules directly from the @primer/css
package:
@import "@primer/css/core/index.scss";
@import "@primer/css/product/index.scss";
@import "@primer/css/marketing/index.scss";
Development
See DEVELOP.md for development docs.
Releasing (for GitHub staff)
You can find docs about our release process in RELEASING.md.
License
Top Related Projects
A utility-first CSS framework for rapid UI development.
Modern CSS framework based on Flexbox
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
The instant on-demand atomic CSS engine.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot