Reading design tokens
Understanding how design tokens are named will help you to use and apply them correctly.
Naming convention
The naming convention enables you to choose a design token that matches your design intent. Design token names may include terms that define the context, object, and modifier for a design token. For example:
[group].[component].[variant/category].[element].[position].[relationship].[property].[type].[scale].[state]
Context
Context provides the circumstances for the design token. For example, action.danger.[…] is the start of a design token that is in an action group of the danger variant. Similarly, banner.promotion.[…] is for a banner component of the promotion variant. Context can be either a group or component, but never both at the same time — the context is either broad or narrow. Design tokens that don't include a context are the most generally applied.
- Group: Broad context that can apply to many things. Examples are
feedback,action, andcontrol. - Component: Narrow context that only applies to the component. Examples are
avatar,button, andtoggle. - Variant/category: Further describes the context. Examples are
confirm,danger, andneutral.
Object
An object is the element that the design decision applies to, and may include its position and relationship to other elements or constraints. For example, […].icon.left.[…] lets you know that the icon element referenced is in the left position. Another example is […].element.to-top.[…] that tells you this is about a generic element's relationship to the top boundary. An object is always present in a semantic and contextual design token name.
- Element: What's being addressed. Examples are
background,border, andtext. - Position: Location of the element. Examples are
top,right, orouter. - Relationship: Association to other elements or constraints. Examples are
to-edge,to-top, andgap.
Modifier
A modifier is an attribute of the object that's being addressed. The property itself can be further described by other modifiers to give it more meaning or to understand how it's being changed. For example, […].color.strong.hover identifies this as a color property that is strong in scale and in the hover state. Likewise, […].font-weight.semibold identifies that the font weight property is semibold in scale.
- Property: Defines what's being addressed. Examples are
color,space, andsize. - Type: Similar to how a variant describes context, the type describes the property. Examples are
info,link, andoverlay. Type can include the same terms as a variant or category, like danger or success, but the same term will never be in two places for a single design token. It's one of the most flexible parts of the naming convention. - Scale: An ordinal range that is finite and doesn't define distance between steps. Example ordinal scale are
default,subtle,strongandsm,md,lg. - State: Interactive or programmatically unique state. Examples include
default,hover, andchecked.
Examples
General design tokens with wide applicability.
More specific design tokens with specific use cases.
The most specific design tokens that are related to components.
Last updated at: