Skip to content

Functional colors

A layer on top of base colors representing properties such as border, background and foreground.

Introduction

The functional system is based on the meaning, or purpose, that colors have in the interface. Use functional design tokens in designs and code to build product interfaces.

By using Primer's functional color system you make sure that your interface:

Foundations

Foundational colors make up most of a product interface.

Foreground

Foundational foreground colors are used for base typeography, icons and component text.

View in Storybook

Background

Foundational background colors apply to surfaces such as pages, boxes and tables.

View in Storybook

Border

Foundational border colors are used to group content or to create a visible separation between sections or items.

View in Storybook

Roles

Role colors highlight affordance or the meaning of elements in the UI.

Neutral

View in Storybook

Accent

Used for interactive elements like links, buttons, form controls (checkboxes, radio buttons, etc.) and the "neutral" variant for banners.

View in Storybook

Success

Used to highlight or emphasize a positive message, or indicate the primary action on a page.

View in Storybook

Attention

Used to highlight or emphasize elements that require the user's attention.

View in Storybook

Severe

Used to highlight or emphasize a level of severity between attention and danger.

View in Storybook

Danger

Use to highlight or emphasize an error or a blocking status, where action is required.

View in Storybook

Open

Used for "open" tasks or workflows.

View in Storybook

Closed

Used for "closed" tasks or workflows.

View in Storybook

Done

Used for "done" tasks or workflows.

View in Storybook

Functional system in action

Table component showing the combination of bg.subtle with border.default, and border.muted

Example of pairing foundation tokens: bg.subtle with border.default, and border.muted.

UI demonstration of what bg.inset looks like. It darkens the background of the whole UI

Thinking in terms of elevation, bg.inset would represent an underground level. It's meant to create a feeling of focus or depth.

Example of a hover style on a list where the background uses bg.accent.emphasis and the text uses fg.onEmphasis.

fg.onEmphasis pairs with bg.[ANY_COLOR_ROLE].emphasis tokens. This example shows fg.onEmphasis paired with bg.accent.emphasis.

Green success alert with check icon, pairing bg.success, fg.success, and border.success color tokens

An example of an alert that pairs bg.success, fg.success, and border.success.

Combining colors

Not all colors pair well with each other. There are combinations of backgrounds and foregrounds that guarantee compliance with WCAG contrast guidelines and a wide range of hierarchical relationships between elements. Never use color on its own to convey a message or meaning. Pair it with explicit text and icons instead.

Pairing color roles

Do

Pair color role foregrounds with their background counterparts or with bg.default and bg.subtle.

Don’t

Never pair emphasis foregrounds with emphasis background.

Color roles and foregrounds

Do

Only use fg.muted with bg.default, bg.subtle, and bg.inset.

Don’t

Never use fg.muted on bg.emphasis or any of the color roles backgrounds.

Color roles recipes

Combination of design tokens 1: bg.[COLOR-ROLE] + border.[COLOR-ROLE] + fg.[COLOR-ROLE]Combination of design tokens 2: bg.[COLOR-ROLE] + border.[COLOR-ROLE].emphasis + fg.[COLOR-ROLE]Combination of design tokens 3: bg.default + border.[COLOR-ROLE].emphasis + fg.[COLOR-ROLE]Combination of design tokens 4: bg.[COLOR-ROLE] + border.[COLOR-ROLE] + fg.default

How to use colors in Primer libraries?

Primer colors exist in different formats and are made available throughout the Primer libraries and tools. Not all colors exist everywhere and the naming depends on the Primer library. Below a list to help find the right Primer color documentation that is specific to that role and environment.

I amDocumentationExample color usage
A product designer working in FigmaPrimer Primitivesbg/accent
An engineer using Primer ViewComponentscolor system argumentsbg: :accent
An engineer using Primer Reactsx propsaccent.subtle
An engineer creating custom UIPrimer CSS color utilitiescolor-bg-accent
A Primer React maintainer creating a componentPrimer Primitives js propertiesaccent.subtle
A Primer CSS maintainer creating a componentPrimer Primitives css variables--color-accent-subtle

Stuck choosing the right color? Feel free to reach out in the #primer Slack channel.