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:
{
"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.
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}.
| Token | Sizes | Weights |
|---|---|---|
font.ui.<size>.<weight> | 6xlarge, 5xlarge, 4xlarge, 3xlarge, 2xlarge, xlarge, large, medium, small, xsmall, 2xsmall | normal, strong, mass, elegant |
font.prose.<size>.<weight> | 6xlarge, 5xlarge, 4xlarge, 3xlarge, 2xlarge, xlarge, large, medium, small, xsmall, 2xsmall | normal, strong, mass, elegant |
font.display.<size>.<weight> | 6xlarge, 5xlarge, 4xlarge, 3xlarge, 2xlarge, xlarge, large, medium, small, xsmall, 2xsmall | normal, strong, mass, elegant |
font.code.<size>.<weight> | xlarge, large, medium, small, xsmall | normal, 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.
| Token | Font family | Font weight | Font size | Line height | Paragraph 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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
font.badge.medium | {font.ui.small.strong} |
font.badge.large | {font.ui.medium.strong} |
font.badge.small | {font.ui.xsmall.strong} |
Breadcrumb
The breadcrumb font sets the text of the pages in a breadcrumb.
| Token | Reference |
|---|---|
font.breadcrumb.page | {font.ui.medium.normal} |
Button
Button fonts set the label of each button size, in the strong weight.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
font.datepicker.day | {font.ui.small.normal} |
font.datepicker.today | {font.ui.small.strong} |
font.datepicker.label | {font.ui.small.strong} |
Dropdown
Dropdown fonts set the title of a dropdown and its items. The title is smaller than the items.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.
| Token | Reference |
|---|---|
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.mediumfor the label of a medium button. - Use a context token for content with a role:
font.context.h2for a heading,font.context.body.mediumfor running text,font.context.label.smallfor 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.
| Platform | Name | Format |
|---|---|---|
| Web | $cx-font-context-jumbo | A Sass map with one key per property |
| iOS | FontContextJumboFontSize | A CGFloat in points |
| Android | @dimen/font_context_jumbo_font_size | A <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.
$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 groupjumbopoints 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
jumboandheroreferencesize.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:
$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.
| Property | iOS | Android |
|---|---|---|
| Font family | FontContextJumboFontFamily | @string/font_context_jumbo_font_family |
| Font weight | FontContextJumboFontWeight | @integer/font_context_jumbo_font_weight |
| Line height | FontContextJumboLineHeight | @dimen/font_context_jumbo_line_height |
| Font size | FontContextJumboFontSize | @dimen/font_context_jumbo_font_size |
| Letter spacing | FontContextJumboLetterSpacing | @dimen/font_context_jumbo_letter_spacing |
| Paragraph spacing | FontContextJumboParagraphSpacing | @dimen/font_context_jumbo_paragraph_spacing |
| Text case | FontContextJumboTextCase | @string/font_context_jumbo_text_case |
| Text decoration | FontContextJumboTextDecoration | @string/font_context_jumbo_text_decoration |
| Font style | FontContextJumboFontStyle | @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:
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:
<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
emon 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
remand iOS in points. Android prints it in ems of the font size of the same token, whichandroid:letterSpacingtakes: the design pixels divided by the font size.
See the web, iOS, and Android docs for the files that hold these names.