![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@primer/primitives
Advanced tools
Color, spacing, and typography primitives for GitHub's Primer design system
This package contains the color, spacing, and typography primitives (AKA constants or "tokens") that form the foundation of Primer, GitHub's design system.
This repository is distributed with npm. You can install it with:
$ npm install --save @primer/primitives
The package's default JavaScript export is an object with the following keys:
colors
is the colors objectspace
is the spacing objectfontSizes
is from typographylineHeights
is from typographyThere are separate exports for colors
, space
, and typography
. For instance, to enumerate the colors:
// all of the following are equivalent:
let {colors} = require('@primer/primitives')
colors = require('@primer/primitives/colors')
colors = require('@primer/primitives/colors.json')
for (const [name, value] of Object.entries(colors)) {
console.log(`colors.${name} = ${JSON.stringify(value)}`)
}
This default export object is suitable for use as a theme source in CSS-in-JS libraries such as styled-components and emotion, and is specifically tailored for use with styled-system's style functions.
Here's an example using styled-components:
import React from 'react'
import styled, {ThemeProvider} from 'styled-components'
import theme from '@primer/primitives'
const Alert = styled.div`
color: ${props => props.theme.colors.green[9]};
background-color: ${props => props.theme.colors.green[2]};
`
const App = props => (
<ThemeProvider theme={theme}>
<Alert />
</ThemeProvider>
)
And styled-system:
import React from 'react'
import styled, {ThemeProvider} from 'styled-components'
import {color} from 'styled-system'
import theme from '@primer/primitives'
const Alert = styled.div`
${color}
`
const App = props => (
<ThemeProvider theme={theme}>
<Alert color='green.0' bg='green.2' {...props} />
</ThemeProvider>
)
Refer to the styled-system table for more information.
The colors object represents Primer's color system. The following keys represent single RGB hex colors:
black
is not "pure" black, but is darker than the darkest graywhite
is pure white (#fff
)The rest of the keys are arrays representing gradients of a certain hue, from lightest to darkest:
gray
blue
green
yellow
orange
red
purple
The space
object is an array of numeric pixel values that represent Primer's spacing scale.
These primitives are the foundation of Primer's typography styles. These keys are merged into the theme object:
fontSizes
represents Primer's font size scale in pixels, from smallest to largest.lineHeights
is an object with keys for each of Primer's named line heights: default
, condensed
, and condensedUltra
.The typography primitives are also available in JavaScript via the @primer/primitives/typography
export, with or without the .json
filename extension.
FAQs
Typography, spacing, and color primitives for Primer design system
The npm package @primer/primitives receives a total of 43,180 weekly downloads. As such, @primer/primitives popularity was classified as popular.
We found that @primer/primitives demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.