Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-news-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'polaris.shopify.com': patch
---

Updated Colors page with v11 content
107 changes: 40 additions & 67 deletions polaris.shopify.com/content/design/colors.md
Original file line number Diff line number Diff line change
@@ -1,111 +1,84 @@
---
title: Colors
description: Our color system builds on the recognition of the Shopify brand colors to make the admin interface more usable.
title: Color
description: Color is a powerful tool that helps merchants quickly navigate and manage their businesses in the Shopify Admin.
icon: ColorsMajor
keywords:
- visual patterns
- color strategy
- color use
---

![Diagram showcasing layers of color of various hues](/images/design/colors/color-intro@2x.png)
![A rainbow of colors created by small bricks](/images/design/colors/color-intro@2x.png)

---

## Principles
## Using color

### Communication is key
![](/images/design/colors/color-usage-123@2x.png)

Although we value an aesthetically pleasing use of color, we place a higher value on clear communication. Color supports the purpose of the content, communicating things like hierarchy of information, interactive states, and the difference between distinct elements.
### 1. Reinforce the purpose of the page

### Colors have meaning
Always use color that supports the purpose of the content and the overall goal of the page. Color can help communicate things like hierarchy of information, interactive states, and distinct elements, all of which make it easier for merchants to get their work done.

Colors have assigned roles, which hold a specific meaning based on how they function within the interface. Defined color roles make things easy to modify and customize later. They also extend the color system so it works across any touchpoint at Shopify.
### 2. Design accessible experiences

### Colors follow accessibility guidelines
The color system is designed to meet WCAG 2.1 contrast ratios. Sufficient contrast makes things easier to find, identify, and interact with for all merchants. However, you should never convey information using color alone. For example, using an icon or a label in addition to using red, yellow, or green when communicating the status of something ensures that the status is visible to merchants who are color blind.

The color system is designed within the HSLuv color space to generate themes that meet WCAG 2.1 compliant contrast ratios. This makes things easier to find, identify, and interact with. It also makes the whole experience more accessible for merchants who are color blind or who have low vision. However you should never convey information using color alone.
### 3. Create heirarchy

---

## Color roles

![Diagram of colors representing the new Polaris color system](/images/design/colors/color-roles@2x.png)

We define colors based on the role they play in the interface. There are 10 color roles, which we use to generate the values of all the color variants in the palette.

![Diagram presenting color variants in a user interface](/images/design/colors/color-variants@2x.png)

### Color variants

Color variants are variables that apply color to the UI, and their values are generated from the color roles. Color variants are available as tokens.

![Diagram presenting a color naming pattern for the color token Border Success Subdued](/images/design/colors/color-variant-naming@2x.png)

Variants share a naming pattern that references their color role, the interaction state they define, and any UI elements they’re linked to.
Color plays a key role in creating the overall hierarchy of a screen. Using the subdued and strong token variants is an easy way to change that hierarchy and draw a merchant's attention to the right place.

---

## The color system in action

How the color roles relate to the variants, and how they’re applied across the interface.

### Surface

Surface colors affect surfaces of components, such as page, card, sheet, and popover.

![Diagram presenting the surface color role, with mainly white and gray colors](/images/design/colors/color-role-surface@2x.png)

### On surface

Apply on-surface colors to elements that appear on neutral surfaces, usually borders, secondary icons, and text elements.

![Diagram presenting the on surface color role, with mainly black and darker gray colors](/images/design/colors/color-role-onsurface@2x.png)

### Primary
## Color pallette

Use primary colors for primary actions like buttons, icons and text on navigation and tabs, and for the background in navigation and tab interactive states.
The Polaris color palette is composed of 8 different colors, each with 10 unique shades. These colors are then used to create semantic tokens that style both Polaris components and custom components within the Shopify admin.

![Diagram presenting the primary color role, with mainly green colors](/images/design/colors/color-role-primary@2x.png)
<!-- colors -->

### Secondary
## Tokens

Use secondary colors for secondary and tertiary buttons and the background of form elements.
![A picture of the admin user interface with overlays showing what parts of the user interface use different color token names](/images/design/colors/color-tokens@2x.png)

![Diagram presenting the secondary color role, with mainly white and gray colors](/images/design/colors/color-role-secondary@2x.png)
Polaris provides a comprehensive suite of [color tokens](/tokens/colors) for styling each part of the user interface. These tokens are passed into components and are available via css variables to style custom UI elements within the Shopify admin.

### Interactive
### Token names

Use interactive colors for things like links, focus indicators, and selected interactive states.
Each color token follows the same naming convention. The purpose and intent of a color token is built into the name itself. This makes it easy to understand how and when any given token should be used.

![Diagram presenting the interactive color role, with mainly blue colors](/images/design/colors/color-role-interactive@2x.png)
**Naming formula:** `--p-color-element-role-variant-state`

### Success
**Example:** `--p-color-bg-critical-subdued-hover`

Success colors indicate something positive, like the success of a merchant action or to illustrate growth.
| Name space | Description | Examples |
| ---------- | --------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| Element | This refers to the actual UI element being styled. | bg, text, icon & border |
| Role | Assigned roles to specific colors to ensure consistent communication of color throughout the admin. | interactive, caution, success, primary, critical, info & magic |
| Variant | This is the key descriptor of a token that communicates exactly what this token is to be used for. | subdued, strong, on-color, inverse |
| State | Communicates the state on which this token is applied. | hover, active, selected, disabled & focus |

![Diagram presenting the success color role, with mainly green colors](/images/design/colors/color-role-success@2x.png)
The element slot is the only one that is required. When there is no role, variant or state associated with a token those slots are omitted from the final token name.

### Warning
### Examples

Warning colors let the merchant know they need to take action, and are applied to badges, banners, and exception lists.
![A list of token name examples showing how the element, role, variant and state are applied to color tokens](/images/design/colors/color-token-naming-example@2x.png)

![Diagram presenting the warning color role, with mainly yellow and orange colors](/images/design/colors/color-role-warning@2x.png)
## Applying tokens

### Critical
### Using color roles

Critical colors are for destructive interactive elements, errors, and critical events that require immediate action.
Colors have assigned roles, which hold a specific meaning based on how they function within the interface. Using these color roles correctly brings consistency across the admin, making it easier for merchants to work.

![Diagram presenting the critical color role, with mainly red colors](/images/design/colors/color-role-critical@2x.png)
![An example of user interface with color roles highlighted](/images/design/colors/color-roles@2x.png)

### Highlight
### Variants

Highlight colors indicate important elements that don’t require immediate action. They’re used with informational banners and badges, indicators that draw attention to new information, loading or progress bars, and data visualization.
Use variants to create hierarchy within the experience. Strong variants put emphasis on an element while subdued variants push them more into the background.

![Diagram presenting the highlight color role, with mainly cyan and teal colors](/images/design/colors/color-role-highlight@2x.png)
![An example of user interface with variants highlighted](/images/design/colors/color-variants@2x.png)

### Decorative
### Interaction states

Decorative colors are for expressive communications that assert the Shopify brand presence.
State tokens make interactions clear to merchants as they manage their store.

![Diagram presenting the decorative color role, with a variety of colors like yellow, turquoise and rose](/images/design/colors/color-role-decorative@2x.png)
![An example of user interface with interaction states highlighted](/images/design/colors/interaction-states@2x.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions polaris.shopify.com/src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,31 @@ button {
.tip-banner__header h4 {
margin: 0 !important;
}

.colors {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: var(--p-space-4);
margin-bottom: var(--p-space-8);
font-size: var(--font-size-75);
font-weight: var(--p-font-weight-semibold);
}

@media (min-width: $breakpointTablet) {
.colors {
grid-template-columns: repeat(10, 1fr);
}
}

.colors-swatch {
position: relative;
overflow: hidden;
border-radius: var(--p-border-radius-2);
margin-bottom: var(--p-space-2);

&:before {
content: "";
display: block;
padding-bottom: 75%;
}
}
40 changes: 40 additions & 0 deletions polaris.shopify.com/src/utils/markdown.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import yaml from 'js-yaml';

import * as colors from '../../../polaris-tokens/dist/esm/src/colors.mjs';

export const parseMarkdown = (inputMarkdown) => {
const readmeSections = inputMarkdown.split('---');
const frontMatterSection = readmeSections[1];
Expand Down Expand Up @@ -66,6 +68,40 @@ export const parseMarkdown = (inputMarkdown) => {
});
}

// Add some custom HTML to <!-- colors --> tags
const colorsRegex = /<!-- (colors) -->/gis;
if (markdown.match(colorsRegex)) {
markdown = markdown.replace(colorsRegex, (match) => {
const colorOrder = [
'gray',
'green',
'teal',
'blue',
'purple',
'red',
'orange',
'yellow',
];

return colorOrder.reduce((acc, color) => {
const shades = colors[color] ?? [];
const swatches = Object.entries(shades)
.sort(([prevShade], [nextShade]) =>
Number(prevShade) < Number(nextShade) ? 1 : -1,
)
.map(
([shade, value]) =>
`<div><div class="colors-swatch" style="background-color: ${value};"></div><div>${shade}</div></div>`,
)
.join('');

return `${acc}<h3>${capitalize(
color,
)}</h3><div class="colors">${swatches}</div>`;
}, '');
});
}

const out = {
frontMatter,
description,
Expand All @@ -74,3 +110,7 @@ export const parseMarkdown = (inputMarkdown) => {

return out;
};

function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
3 changes: 2 additions & 1 deletion polaris.shopify.com/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"**/*.json",
"next-env.d.ts",
"scripts/get-props/src/get-props.ts",
"constants.js"
"constants.js",
"../polaris-tokens/dist"
],
"exclude": ["node_modules", "scripts/get-props/testData"]
}