diff --git a/contributor-docs/adrs/adr-006-naming-design-tokens.md b/contributor-docs/adrs/adr-006-naming-design-tokens.md new file mode 100644 index 000000000..90a9ca4ed --- /dev/null +++ b/contributor-docs/adrs/adr-006-naming-design-tokens.md @@ -0,0 +1,200 @@ +# Design token naming guidelines + +## Status + +| Stage | Status | +| -------- | ------ | +| Approved | ✅ | +| Adopted | ✅ | + +## Context + +In an effort to strengthen and extend Primer's design data layer, `primer-primitives`, the team has designed a new set of tokens that systemize sizing, spacing, typography and more in a way that any Primer framework can consume (see related [epic](https://github.com/github/primer/issues/681)). + +With the addition of this expanded set of design tokens, we need a standard naming convention to ensure consistency across token groups. A standard naming convention helps us better communicate, document, and author design tokens. + +This convention applies to all tokens including component, sizing, spacing, typography, motion and color. + +## Decision + +The design token naming convention will be based on three categories: **base, component/pattern, functional**. Each category is a subset of the over-arching convention. + +`prefix-namespace-pattern-variant*-property-variant*-scale` + +\*variant scope changes based on the category + + + +## Base + +Base tokens represent global, constant values. These are the lowest level tokens and map directly to a raw value. + + + +[prefix]-[namespace*]-[property*]-[variant]-[scale] + +### Example `base` tokens + +``` +brand-base-color-lime-5 +base-size-4 +base-color-green-5 +base-fontWeight-semibold +``` + +## Functional + + + +[prefix]-[property*]-[variant]-[scale] + +``` +bgColor-inset +borderColor-default +brand-borderWidth-thin +boxShadow-inset-thick +``` + +## Component/pattern + +Component/pattern represents component and pattern specific tokens which should only be used in component CSS. + + + +[prefix]-[pattern*]-[variant]-[property*]-[scale] + +### Example `component`/`pattern` tokens + +``` +control-danger-bgColor-hover +button-primary-bgColor-rest +brand-control-xsmall-paddingInline-normal +text-codeInline-fontSize +``` + +## Naming convention + +### Prefix + +**[prefix]**-[namespace]-[pattern]-[variant]-[property]-[variant]-[scale] + +Prefix provides top-level encapsulation of a particular flavor of Primer, such as Primer Brand. It can be used for protected base tokens like Brand color scales, or value overrides for traditional Primer tokens in order to avoid collisions. + +`brand-`: used for marketing/brand specific tokens. + +### Namespace + +[prefix]-**[namespace]**-[pattern]-[variant]-[property]-[variant]-[scale] + +Namespace creates a scope used to identify how a token may be used. For example, `base` tokens are the lowest level and are generally used as a reference for functional tokens (the next step above). + +`base-`: represents global, constant values. These are the lowest level tokens and map directly to a raw value. + +### Pattern + +[prefix]-[namespace]-**[pattern]**-[variant]-[property]-[variant]-[scale] + +Pattern represents a group of design decisions, or a specific Primer component. Whenever possible, aim to use a name that is generic enough to influence related components. In the example below, the item `control` can be used for multiple types of controls like buttons, inputs, or interactive action list items. + +For pattern and component names that are multi-word, use camelCase to separate each word. + +✅ + +**underlineNav**-borderColor-active + +❌ + +**UnderlineNav**-borderColor-active + +