All Projects → Shopify → Polaris Tokens

Shopify / Polaris Tokens

Licence: mit
Design tokens for Polaris, Shopify’s design system

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Polaris Tokens

Evergreen
🌲 Evergreen React UI Framework by Segment
Stars: ✭ 11,340 (+6690.42%)
Mutual labels:  design-systems
Moonmail
Email marketing platform for bulk emailing via Amazon SES (Google Cloud Platform and Azure coming soon)
Stars: ✭ 1,766 (+957.49%)
Mutual labels:  shopify
Ob Low Impact Website
The Low Impact version of the Organic Basics website
Stars: ✭ 147 (-11.98%)
Mutual labels:  shopify
React
Modern and minimalist React UI library.
Stars: ✭ 2,546 (+1424.55%)
Mutual labels:  design-systems
Shopify Modern
A modern template for developing Shopify-themes using Vuejs
Stars: ✭ 136 (-18.56%)
Mutual labels:  shopify
Sneaker Monitors
A collection of web monitors that notify of restocks or updates on sneaker related sites through Discord Webhook. This includes Shopify, Nike SNKRS (supports 42 countries), Supreme and now Footsite monitor!
Stars: ✭ 130 (-22.16%)
Mutual labels:  shopify
Ui Ux
📝 Curated list for UI/UX Designers
Stars: ✭ 125 (-25.15%)
Mutual labels:  design-systems
Fractal
A tool to help you build and document website component libraries and design systems.
Stars: ✭ 2,003 (+1099.4%)
Mutual labels:  design-systems
Basic Shopify Api
A simple API wrapper for Shopify using Guzzle for REST and GraphQL
Stars: ✭ 137 (-17.96%)
Mutual labels:  shopify
Html Sketchapp
HTML to Sketch export solution
Stars: ✭ 1,811 (+984.43%)
Mutual labels:  design-systems
Paris
Define and apply styles to Android views programmatically
Stars: ✭ 1,716 (+927.54%)
Mutual labels:  design-systems
Balm Ui
♦️ A modular and customizable UI library based on Material Design and Vue
Stars: ✭ 133 (-20.36%)
Mutual labels:  design-systems
You Dont Know Ui
Learn how to build universal, modern and scalable user interfaces
Stars: ✭ 140 (-16.17%)
Mutual labels:  design-systems
Toolkit
Sky's CSS Toolkit
Stars: ✭ 126 (-24.55%)
Mutual labels:  design-systems
Patternlab Node
The Node version of Pattern Lab
Stars: ✭ 1,898 (+1036.53%)
Mutual labels:  design-systems
Tachyons
Functional css for humans
Stars: ✭ 11,057 (+6520.96%)
Mutual labels:  design-systems
X0
Document & develop React components without breaking a sweat
Stars: ✭ 1,706 (+921.56%)
Mutual labels:  design-systems
Vue Design System
An open source tool for building UI Design Systems with Vue.js
Stars: ✭ 2,077 (+1143.71%)
Mutual labels:  design-systems
Shopify Webpack Themekit
Shopify development tool using webpack and themekit
Stars: ✭ 157 (-5.99%)
Mutual labels:  shopify
Openship
e-commerce automation
Stars: ✭ 143 (-14.37%)
Mutual labels:  shopify

Polaris design tokens

Colors, spacing, animation, and typography for all platforms

JavaScript · JSON · CSS · SCSS · Android · Sketch · macOS · iOS · Adobe Swatch

npm version CI


Design tokens for Polaris, Shopify’s design system.

Design tokens originated at Salesforce, and the best way to describe them is to simply quote their documentation:

Design tokens are the visual design atoms of the design system — specifically, they are named entities that store visual design attributes. We use them in place of hard-coded values (such as hex values for color or pixel values for spacing) in order to maintain a scalable and consistent visual system for UI development – Salesforce UX

Installation

Polaris design tokens are available as both a npm package (@shopify/polaris-tokens) on npm, and as a Ruby gem (polaris_tokens) on RubyGems.

The recommended way to use and install design tokens may vary depending on your project; the most common are documented below.

Using npm:

npm install @shopify/polaris-tokens --save

Using yarn:

yarn add @shopify/polaris-tokens

Using Bundler:

bundle add polaris_tokens

Usage

Find all available tokens in the design tokens documentation.

JavaScript

In JavaScript, design token names are formatted in lower camelCase.

const tokens = require('@shopify/polaris-tokens');
console.log(tokens.colorBlueLighter); // rgb(235, 245, 250)

In JSON, design token names are formatted in kebab-case.

const tokens = require('@shopify/polaris-tokens/dist/index.json');
console.log(tokens['color-blue-lighter']); // rgb(235, 245, 250)

Note that, if your project supports ECMAScript Modules, you can also use the import syntax.

import * as tokens from '@shopify/polaris-tokens';
// or
import {colorBlueLighter} from '@shopify/polaris-tokens';

Sass

Sass variables and map keys are formatted in kebab-case.

// Using variables
@import '[email protected]/polaris-tokens/dist/index';

a {
  color: $color-blue-text;
}

// Using the map of all tokens
@import '[email protected]/polaris-tokens/dist/index.map';

a {
  color: map-get($polaris-index-map, 'color-blue-text');
}

// Using the map for a specific type of tokens (here: spacing)
@import '[email protected]/polaris-tokens/dist/spacing.spacing-map';

a {
  color: map-get($polaris-spacing-map, 'loose');
}

Sass, with CSS Custom Properties

Custom properties are formatted in kebab-case.

// Omit .css at the end of the file
@import '[email protected]/polaris-tokens/dist/colors.custom-properties';

a {
  color: var(--color-blue-text);
}

Rails

Token files are added to the assets pipeline. In JSON, design token names are formatted in kebab-case.

require 'json'
polaris_token_file = Rails.application.assets_manifest.find_sources('colors.json').first
polaris_colors = JSON.parse(polaris_token_file)
polaris_colors['color-blue-lighter'] # "rgb(235, 245, 250)"

CSS Filters

Color tokens include a CSS Filter (filter) value as part of their metadata. When this filter is applied to an element, it will change that element’s color to approximate the target token color.

<div>
  No background, no filter
</div>

<div style="background-color: #fff">
  White background, no filter
</div>

<div style="filter: brightness(0) saturate(100%) invert(28%) sepia(67%) saturate(3622%) hue-rotate(353deg) brightness(89%) contrast(95%)">
  No background, red filter
</div>

<div style="background-color: #fff; filter: brightness(0) saturate(100%) invert(28%) sepia(67%) saturate(3622%) hue-rotate(353deg) brightness(89%) contrast(95%)">
  White background, red filter
</div>

text and non-transparent backgrounds become red when filter is applied

In general, these filters shouldn’t be used unless absolutely necessary. The main use case for the filters is to apply a color to an unsafe (as in: user-provided) SVG. Since SVGs can contain arbitrary code, we should be careful about how they are displayed. The safest option is to render SVGs as an img (for example <img src="circle.svg" alt="" />); when SVGs are rendered like this, browsers will block code execution. Unfortunately, it also means that the SVGs cannot be styled with external CSS (applying fill: red to the img won’t do anything.)

CSS filters allow us the safety of rendering SVGs inside img elements, but still give us control over their appearance.

<div>
  <img src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><circle cx='20' cy='20' r='16' /></svg>" alt="" /> black circle, no filter
</div>
<div>
  <img src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><circle cx='20' cy='20' r='16' /></svg>" style="filter: brightness(0) saturate(100%) invert(28%) sepia(67%) saturate(3622%) hue-rotate(353deg) brightness(89%) contrast(95%)" alt="" /> black circle, red filter
</div>

the filter turns the black circle red

Note that all filled areas of an SVG will change color with this approach, including borders/strokes. For that reason it should only be used with monochromatic SVGs.

<div>
  <img src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><circle cx='20' cy='20' r='16' stroke='green' stroke-width='4' /></svg>" alt="" /> black circle with green border, no filter
</div>
<div>
  <img src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50'><circle cx='20' cy='20' r='16' stroke='green' stroke-width='4' /></svg>" style="filter: brightness(0) saturate(100%) invert(28%) sepia(67%) saturate(3622%) hue-rotate(353deg) brightness(89%) contrast(95%)" alt="" /> black circle with green border, red filter
</div>

the filter turns the entire circle red, including the border

If you need to generate new filter values, you can do so with this CodePen.


Contributing

The purpose of this repository is to see the core design elements of the Polaris design system evolve and improve over time with the needs of developers, designers and partners in mind.

We gratefully accept impromptu contributions to the documentation, typo and bug fixes, and expect design token requests and changes to be discussed before a pull request.

Code of conduct

We have a code of conduct, please follow it in all your interactions with the project.

Contributing guide

Read the contributing guide to learn how to propose changes and understand our development process.

License

The polaris-tokens project is available under the MIT license.

Parts of the code in this repository are directly inspired or borrowed from the Theo project, property of Salesforce.com, Inc., licensed under BSD 3-Clause.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].