✨ Introducing Primer Primitives v8.0! ✨ #822
lukasoppermann
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Note
This was moved over from primer/primitives as we close discussions over there.
Primitives v8.0 introduces a re-imagined design token build process, a token naming convention, and new tokens to handle sizing, spacing and typography. These changes have been tested behind the scenes for the past year, and are now becoming the default experience with this major release.
New features and improvements
dist
, whereas previously they needed to be consumed through Primer CSSrem
unitsBreaking changes
scale
color tokens are abstracted from the built color CSS, and only used internallyjs
,scss
,ts
outputUpgrade guide
Upgrading from v7 to v8
npm install @primer/primitives@latest
Everything new in v8 is available in v7 today. If you would prefer to do a slower upgrade, you can start importing new colors and variables from
dist
before bumping to v8:Sizing, spacing & typography
Colors
CSS and SCSS usage
If you're consuming Primer themes via Primer CSS with
.scss
files:primer/primitives
(see imports above)Using stylelint to autofix color token names
npm install @primer/stylelint-config@latest
In your stylelint config file, add the following plugins:
If you would like to do a slower upgrade to v8, you can use this flag with
no-deprecated-colors
which will provide a fallback value:Using
inlineFallback
will result in something like this, where the new color var has fallback value to the old:color: var(--fgColor-default, var(--color-fg-default));
React usage
If you're consuming Primer themes via Primer React, you will notice the existing themes now reference CSS variables under the hood with a fallback value. Consider importing the CSS file imports listed above into your app to take advantage of these new values.
sx
propIf you're already referencing CSS variables as a string via the
sx
prop, you can use our custom eslint plugin to help autofix to the new color variables.npm install --save-dev eslint-plugin-primer-react
Reference the plugin in your eslint config:
If you would like to do a slower upgrade to v8, you can use the new-color-css-vars-have-fallback plugin which will provide a fallback value:
Using the fallback plugin will result in something like this:
<Button sx={{color: 'var(--fgColor-muted, var(--color-fg-muted))'}}>Test</Button>
Color scale usage
In v8.0, the range of
scale
colors such as--color-scale-red-x
have been removed from the dist files. This change is designed to better enforce proper color contrast between foreground and background colors. Our functional color tokens were designed to not only handle theming and color mode changes, but ensure adequate contrast when they are combined.If you're currently using
scale
colors directly, you can reference our color documentation to find the next closest functional color variable to swap in.Documentation
See Primer Primitives documentation for more detailed guidelines and lists of available CSS variables.
For a more detailed explanation of our color system, check out the color documentation.
Support
If you have any issues upgrading or need help finding replacement color tokens for legacy values, feel free to comment on this discussion or open an issue!
Beta Was this translation helpful? Give feedback.
All reactions