Skip to main contentSkip to docs navigation

Chassis

Font Tokens

View on GitHub

Composite tokens that combine the typography properties into text styles, with the references of each level and their format on each platform.

This page is a work in progress. Parts of it may be incomplete or differ from the current version of Chassis Tokens.

Introduction

The token sets that this page names are the Chassis token system, as chassis-tokens init writes it into a repository of tokens. Once written, the token sets belong to the repository, which changes them as it needs.

Font tokens are composite tokens: each holds a whole text style, where a typography token holds one property. A font token has the type typography, and its value is an object with a font family, a font weight, a font size, a line height, a letter spacing, and a paragraph spacing. No font token names a text case or a text decoration.

Each property references a typography token, as font.ui.medium.strong shows in source/base/app-base.json:

JSON
{
  "font": {
    "ui": {
      "medium": {
        "strong": {
          "$type": "typography",
          "$value": {
            "fontFamily": "{typography.fontFamily.ui}",
            "fontWeight": "{typography.fontWeight.ui.strong}",
            "lineHeight": "{typography.lineHeight.ui.medium}",
            "fontSize": "{typography.fontSize.ui.medium}",
            "letterSpacing": "{typography.letterSpacing.ui.strong}",
            "paragraphSpacing": "{typography.paragraphSpacing.base.zero}"
          }
        }
      }
    }
  }
}

The build adds one more property, the font style, which it takes from the font weight: normal, or the style that the weight names, such as italic.

Font tokens hold references, so their values follow the typography tokens. A brand changes the text styles by overriding the font families and the font weights, or the typography tokens of one text role or role group, and no font token has to change. A repository that adds the optional screen group can give a font token a font size per screen.

Token levels

Font tokens have three levels. Base tokens combine the typography tokens of one family, one size, and one weight. Context tokens combine the typography tokens of one text role. Component tokens hold a reference to a base token.

TEXT
typography.fontFamily.ui
typography.fontWeight.ui.strong
typography.fontSize.ui.medium
typography.lineHeight.ui.medium
  font.ui.medium.strong               references them
    font.button.medium                {font.ui.medium.strong}

Base tokens

Base tokens are named font.<family>.<size>.<weight>. Each combines the family, the weight, the font size, and the line height that the typography tokens hold under the same names: font.prose.large.mass references {typography.fontFamily.prose}, {typography.fontWeight.prose.mass}, {typography.fontSize.prose.large}, and {typography.lineHeight.prose.large}.

TokenSizesWeights
font.ui.<size>.<weight>6xlarge, 5xlarge, 4xlarge, 3xlarge, 2xlarge, xlarge, large, medium, small, xsmall, 2xsmallnormal, strong, mass, elegant
font.prose.<size>.<weight>6xlarge, 5xlarge, 4xlarge, 3xlarge, 2xlarge, xlarge, large, medium, small, xsmall, 2xsmallnormal, strong, mass, elegant
font.display.<size>.<weight>6xlarge, 5xlarge, 4xlarge, 3xlarge, 2xlarge, xlarge, large, medium, small, xsmall, 2xsmallnormal, strong, mass, elegant
font.code.<size>.<weight>xlarge, large, medium, small, xsmallnormal, strong

A base token of the ui, prose, or display family takes its letter spacing from its weight, such as {typography.letterSpacing.prose.mass}, and font.code.* references {typography.letterSpacing.base.zero}. Every base token references {typography.paragraphSpacing.base.zero}.

Context tokens

Context tokens name a text style by its role in the content. Each takes its properties from the typography tokens of its role, in the context group of source/base/brand-base.json, which a brand can override. The font size, the line height, and the letter spacing belong to the role, such as {typography.fontSize.context.h1} and {typography.letterSpacing.context.h1}. The family and the weight belong to the role group, which the roles of the group share: font.context.h1 to font.context.h6 reference {typography.fontFamily.context.heading} and {typography.fontWeight.context.heading}. The table shows the other properties that change with the role.

TokenFont familyFont weightFont sizeLine heightParagraph spacing
font.context.jumbo{typography.fontFamily.context.jumbo}{typography.fontWeight.context.jumbo}{typography.fontSize.context.jumbo}{typography.lineHeight.context.jumbo}{typography.paragraphSpacing.base.zero}
font.context.hero{typography.fontFamily.context.hero}{typography.fontWeight.context.hero}{typography.fontSize.context.hero}{typography.lineHeight.context.hero}{typography.paragraphSpacing.base.zero}
font.context.h1{typography.fontFamily.context.heading}{typography.fontWeight.context.heading}{typography.fontSize.context.h1}{typography.lineHeight.context.h1}{typography.paragraphSpacing.base.zero}
font.context.h2{typography.fontFamily.context.heading}{typography.fontWeight.context.heading}{typography.fontSize.context.h2}{typography.lineHeight.context.h2}{typography.paragraphSpacing.base.zero}
font.context.h3{typography.fontFamily.context.heading}{typography.fontWeight.context.heading}{typography.fontSize.context.h3}{typography.lineHeight.context.h3}{typography.paragraphSpacing.base.zero}
font.context.h4{typography.fontFamily.context.heading}{typography.fontWeight.context.heading}{typography.fontSize.context.h4}{typography.lineHeight.context.h4}{typography.paragraphSpacing.base.zero}
font.context.h5{typography.fontFamily.context.heading}{typography.fontWeight.context.heading}{typography.fontSize.context.h5}{typography.lineHeight.context.h5}{typography.paragraphSpacing.base.zero}
font.context.h6{typography.fontFamily.context.heading}{typography.fontWeight.context.heading}{typography.fontSize.context.h6}{typography.lineHeight.context.h6}{typography.paragraphSpacing.base.zero}
font.context.lead{typography.fontFamily.context.lead}{typography.fontWeight.context.lead}{typography.fontSize.context.lead}{typography.lineHeight.context.lead}{typography.paragraphSpacing.base.zero}
font.context.blockquote{typography.fontFamily.context.blockquote}{typography.fontWeight.context.blockquote}{typography.fontSize.context.blockquote}{typography.lineHeight.context.blockquote}{typography.paragraphSpacing.base.zero}
font.context.cite{typography.fontFamily.context.cite}{typography.fontWeight.context.cite}{typography.fontSize.context.cite}{typography.lineHeight.context.cite}{typography.paragraphSpacing.base.zero}
font.context.body.large{typography.fontFamily.context.body}{typography.fontWeight.context.body}{typography.fontSize.context.body-large}{typography.lineHeight.context.body-large}{typography.paragraphSpacing.base.large}
font.context.body.medium{typography.fontFamily.context.body}{typography.fontWeight.context.body}{typography.fontSize.context.body-medium}{typography.lineHeight.context.body-medium}{typography.paragraphSpacing.base.medium}
font.context.body.small{typography.fontFamily.context.body}{typography.fontWeight.context.body}{typography.fontSize.context.body-small}{typography.lineHeight.context.body-small}{typography.paragraphSpacing.base.small}
font.context.title.large{typography.fontFamily.context.title}{typography.fontWeight.context.title}{typography.fontSize.context.title-large}{typography.lineHeight.context.title-large}{typography.paragraphSpacing.base.large}
font.context.title.medium{typography.fontFamily.context.title}{typography.fontWeight.context.title}{typography.fontSize.context.title-medium}{typography.lineHeight.context.title-medium}{typography.paragraphSpacing.base.medium}
font.context.title.small{typography.fontFamily.context.title}{typography.fontWeight.context.title}{typography.fontSize.context.title-small}{typography.lineHeight.context.title-small}{typography.paragraphSpacing.base.small}
font.context.label.large{typography.fontFamily.context.label}{typography.fontWeight.context.label}{typography.fontSize.context.label-large}{typography.lineHeight.context.label-large}{typography.paragraphSpacing.base.zero}
font.context.label.medium{typography.fontFamily.context.label}{typography.fontWeight.context.label}{typography.fontSize.context.label-medium}{typography.lineHeight.context.label-medium}{typography.paragraphSpacing.base.zero}
font.context.label.small{typography.fontFamily.context.label}{typography.fontWeight.context.label}{typography.fontSize.context.label-small}{typography.lineHeight.context.label-small}{typography.paragraphSpacing.base.zero}

The headings are named after their HTML elements, so font.context.h1 is the style of an h1. font.context.blockquote gets the font style italic from its weight. The typography tokens reference lists the roles and their role groups.

Component tokens

Component tokens assign a base token of the ui family to a part of a component. A component token holds the reference only, so it has the properties of the base token it names.

Accordion

Accordion fonts set the title and the body of each accordion size.

TokenReference
font.accordion.medium-title{font.ui.medium.strong}
font.accordion.medium-body{font.ui.medium.normal}
font.accordion.large-title{font.ui.large.strong}
font.accordion.large-body{font.ui.large.normal}
font.accordion.small-title{font.ui.small.strong}
font.accordion.small-body{font.ui.small.normal}

Alert

Alert fonts set the title and the body of each alert size. The title is one step larger than the body.

TokenReference
font.alert.large-title{font.ui.xlarge.strong}
font.alert.large-body{font.ui.large.normal}
font.alert.small-title{font.ui.large.strong}
font.alert.small-body{font.ui.medium.normal}

Assist

Assist fonts hold one text style per size, in the normal weight.

TokenReference
font.assist.medium{font.ui.medium.normal}
font.assist.large{font.ui.large.normal}
font.assist.small{font.ui.small.normal}

Badge

Badge fonts are one step smaller than their name says: font.badge.medium references the small step of the ui family.

TokenReference
font.badge.medium{font.ui.small.strong}
font.badge.large{font.ui.medium.strong}
font.badge.small{font.ui.xsmall.strong}

The breadcrumb font sets the text of the pages in a breadcrumb.

TokenReference
font.breadcrumb.page{font.ui.medium.normal}

Button

Button fonts set the label of each button size, in the strong weight.

TokenReference
font.button.medium{font.ui.medium.strong}
font.button.large{font.ui.large.strong}
font.button.small{font.ui.small.strong}

Card

Card fonts set the title, the subtitle and the body of each card size. The title is one step larger than the body, and the subtitle one step smaller, in the strong weight.

TokenReference
font.card.medium-title{font.ui.large.strong}
font.card.medium-subtitle{font.ui.small.strong}
font.card.medium-body{font.ui.medium.normal}
font.card.large-title{font.ui.xlarge.strong}
font.card.large-subtitle{font.ui.medium.strong}
font.card.large-body{font.ui.large.normal}
font.card.small-title{font.ui.medium.strong}
font.card.small-subtitle{font.ui.xsmall.strong}
font.card.small-body{font.ui.small.normal}

Chip

Chip fonts reference the same base tokens as the badge fonts, one step smaller than their name.

TokenReference
font.chip.medium{font.ui.small.strong}
font.chip.large{font.ui.medium.strong}
font.chip.small{font.ui.xsmall.strong}

Date picker

Datepicker fonts share the small step. The current day and the labels have the strong weight, the other days the normal weight.

TokenReference
font.datepicker.day{font.ui.small.normal}
font.datepicker.today{font.ui.small.strong}
font.datepicker.label{font.ui.small.strong}

Dropdown fonts set the title of a dropdown and its items. The title is smaller than the items.

TokenReference
font.dropdown.title{font.ui.small.strong}
font.dropdown.item{font.ui.medium.normal}

Form input

Form input fonts set the label and the text of each input size. The floating tokens belong to the input with a floating label, whose label is xsmall.

TokenReference
font.form-input.medium-label{font.ui.medium.strong}
font.form-input.large-label{font.ui.large.strong}
font.form-input.small-label{font.ui.small.strong}
font.form-input.medium-text{font.ui.medium.normal}
font.form-input.large-text{font.ui.large.normal}
font.form-input.small-text{font.ui.small.normal}
font.form-input.floating-text{font.ui.medium.normal}
font.form-input.floating-label{font.ui.xsmall.normal}

Modal fonts set the title and the subtitle of each modal size. The title changes with the size; the subtitle is the same in every size.

TokenReference
font.modal.large-title{font.ui.xlarge.strong}
font.modal.large-subtitle{font.ui.medium.normal}
font.modal.medium-title{font.ui.large.strong}
font.modal.medium-subtitle{font.ui.medium.normal}
font.modal.small-title{font.ui.medium.strong}
font.modal.small-subtitle{font.ui.medium.normal}

Notification

Notification fonts set the title and the message of a notification.

TokenReference
font.notification.title{font.ui.large.strong}
font.notification.message{font.ui.medium.normal}

Page

Page fonts set the title and the subtitle of each page size. The large and the medium title reference the same base token.

TokenReference
font.page.large-title{font.ui.2xlarge.strong}
font.page.large-subtitle{font.ui.medium.normal}
font.page.medium-title{font.ui.2xlarge.strong}
font.page.medium-subtitle{font.ui.medium.normal}
font.page.small-title{font.ui.xlarge.strong}
font.page.small-subtitle{font.ui.medium.normal}

Section

Section fonts set the header of each section size.

TokenReference
font.section.header-large{font.ui.large.strong}
font.section.header-medium{font.ui.medium.strong}
font.section.header-small{font.ui.small.strong}

Segment

Segment fonts are one step smaller than their name, as the badge fonts are, in the normal weight.

TokenReference
font.segment.medium{font.ui.small.normal}
font.segment.large{font.ui.medium.normal}
font.segment.small{font.ui.xsmall.normal}

Tab

Tab fonts reference the same base tokens as the button fonts.

TokenReference
font.tab.medium{font.ui.medium.strong}
font.tab.large{font.ui.large.strong}
font.tab.small{font.ui.small.strong}

Table

Table fonts share the small step. The head has the strong weight, the data the normal weight.

TokenReference
font.table.data-text{font.ui.small.normal}
font.table.head-text{font.ui.small.strong}

Usage

Choose the level that names the text:

  • Use a component token for the part of a component that it names, such as font.button.medium for the label of a medium button.
  • Use a context token for content with a role: font.context.h2 for a heading, font.context.body.medium for running text, font.context.label.small for the label of a control.
  • Use a base token where no context or component token fits: font.ui.* in an interface, font.prose.* in reading content, font.display.* for display text that has no role.

To set the text of a role in the display family, point the family and the weight of its role group at the display family in the token set of the brand, as Usage of the typography tokens shows. A font token takes its weight from the family it takes its family from, which chassis-tokens lint-source checks.

Give a new component token a reference to a base token of the ui family, as the existing component tokens have. The token then follows the typography scales and the fonts of each brand.

A font token holds no color. Set the color of a text with a color token.

Platform output

A font token prints as one Sass map on the web, and as one constant or resource per property on iOS and Android. The table shows the font size of font.context.jumbo on iOS and Android.

PlatformNameFormat
Web$cx-font-context-jumboA Sass map with one key per property
iOSFontContextJumboFontSizeA CGFloat in points
Android@dimen/font_context_jumbo_font_sizeA <dimen> in sp

The values in the examples of this section are those of the token sets that init writes, and a brand that overrides a token has its own.

The build writes the map of the web to main.scss, on one line. The keys are CSS properties: the paragraph spacing is margin-bottom, and the text case is text-transform. Every map has the keys text-transform and text-decoration, and a font token that names no text case or text decoration has none for it, on every platform.

SCSS
$cx-font-context-jumbo: ("font-family": var(--font-family-display), "font-weight": var(--font-weight-display-strong), "font-size": 6rem, "line-height": var(--line-height-jumbo), "font-style": normal, "letter-spacing": 0rem, "margin-bottom": 0rem, "text-transform": none, "text-decoration": none) !default;

The web platform names the custom properties of Chassis CSS for the family, the weight, the font size, and the line height that a font token references, so its maps work with Chassis CSS only:

  • A base token names the properties of its family and step, such as var(--font-size-ui-md), and a component token names those of the base token it references.
  • A context token names the family and the weight that its role group points to in the brand: var(--font-family-display) in the example, where the role group jumbo points at the display family, and the property of another family in a brand that points the group at it.
  • A context token names the font size and the line height of its role, without the group and with the short name of the size: var(--font-size-h1), var(--line-height-title-lg).
  • A role whose size references another group, as jumbo and hero reference size.unit.*, prints the size, and a role group that holds a value of its own prints the value.

$cx-font-context-h1 shows the custom properties of a role:

SCSS
$cx-font-context-h1: ("font-family": var(--font-family-display), "font-weight": var(--font-weight-display-strong), "font-size": var(--font-size-h1), "line-height": var(--line-height-h1), "font-style": normal, "letter-spacing": 0rem, "margin-bottom": 0rem, "text-transform": none, "text-decoration": none) !default;

The presets web-scss, web-px, and web-vw print the values; see the Style Dictionary page.

iOS and Android name each constant or resource after the token and the property. The format of a property is the format of its typography token, except for the line height and the letter spacing.

PropertyiOSAndroid
Font familyFontContextJumboFontFamily@string/font_context_jumbo_font_family
Font weightFontContextJumboFontWeight@integer/font_context_jumbo_font_weight
Line heightFontContextJumboLineHeight@dimen/font_context_jumbo_line_height
Font sizeFontContextJumboFontSize@dimen/font_context_jumbo_font_size
Letter spacingFontContextJumboLetterSpacing@dimen/font_context_jumbo_letter_spacing
Paragraph spacingFontContextJumboParagraphSpacing@dimen/font_context_jumbo_paragraph_spacing
Text caseFontContextJumboTextCase@string/font_context_jumbo_text_case
Text decorationFontContextJumboTextDecoration@string/font_context_jumbo_text_decoration
Font styleFontContextJumboFontStyle@string/font_context_jumbo_font_style

The build writes the sizes of a font token to the number file, one per screen when the repository has screens, and the other properties to the string file. The main file holds all of them. On iOS, Number.swift has these lines:

SWIFT
    public static let FontContextJumboLineHeight = CGFloat(120)
    public static let FontContextJumboFontSize = CGFloat(96)
    public static let FontContextJumboLetterSpacing = CGFloat(0)
    public static let FontContextJumboParagraphSpacing = CGFloat(0)

On Android, number.xml has the same properties:

XML
  <dimen name="font_context_jumbo_line_height">120sp</dimen>
  <dimen name="font_context_jumbo_font_size">96sp</dimen>
  <item name="font_context_jumbo_letter_spacing" type="dimen" format="float">0</item>
  <dimen name="font_context_jumbo_paragraph_spacing">0sp</dimen>

The line height and the letter spacing print by rules of their own inside a font token:

  • A line height that is a percentage prints in em on the web. iOS and Android print a size: that percentage of the font size of the same token.
  • The letter spacing is in design pixels, the same at every font size, as in Figma. The web prints it in rem and iOS in points. Android prints it in ems of the font size of the same token, which android:letterSpacing takes: the design pixels divided by the font size.

See the web, iOS, and Android docs for the files that hold these names.