Skip to main contentSkip to docs navigation

Chassis

Size Tokens

View on GitHub

Size tokens hold the widths and heights of components, icons, and layout parts, from the base scale to the sizes of each component.

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.

Size tokens hold the dimensions of an element: the height of a button, the size of an icon, the width of a modal window. The whitespace inside and between elements belongs to the space tokens, whose page has the same sections as this one.

A size is a number of design pixels, and the build converts it to the unit of each platform, as Platform output shows. In the token sets that init writes, no brand, theme, or app overrides a size token. A repository that adds the optional screen group can give a component token a value per screen; init writes no such group.

Token levels

Each level references the level below it, so a size is written once, in dimension.base.*. The chain of one step shows the three levels:

TEXT
dimension.base.16                  holds the size
└── size.unit.16                   {dimension.base.16}
    ├── size.context.2xsmall       {size.unit.16}
    ├── size.icon.glyph.xsmall     {size.unit.16}
    └── size.button.small-caret    {size.unit.16}

Context and component tokens both reference size.unit.*. No component token references size.context.*, so a change to size.context.medium leaves size.button.medium-main as it is. The token sets of each level are files of source/:

LevelTokensReferencesToken set
Basedimension.base.*Nonebase/metric-source.json
Basesize.unit.*dimension.base.*base/metric-base.json
Contextsize.context.*, size.icon.glyph.*, size.asset.*size.unit.*base/app-base.json
Componentsize.<component>.*size.unit.*base/app-base.json

Base tokens

The base level holds the scale. dimension.base.* holds the sizes, and size.unit.* references them one to one under the name of the category.

Dimension scale

dimension.base.* holds a size in design pixels, and the name of a step states that size: dimension.base.16 is sixteen design pixels. The steps are close together at the start of the scale and further apart toward its end. The size, space, border radius, and shadow tokens reference this scale.

A step that is not a positive whole number has a prefix:

  • d marks a fraction: d15 is one and a half, and d25 is two and a half.
  • 05 and d05 are both a half.
  • n marks a negative size: n4 is minus four, and nd15 is minus one and a half.

Size units

size.unit.* has a token for every step of the dimension scale, under the name of the step: size.unit.16 references {dimension.base.16}, and size.unit.n4 references {dimension.base.n4}. The context and component tokens of this page reference these tokens.

Grid tokens

grid.* is a group of its own, next to size.*, in base/app-base.json. It holds the measures of the layout grid, named grid.<part>.<step> with the steps xsmall, small, medium, large, xlarge, and 2xlarge. The tokens hold a value of their own, reference no step of the scale, and are the same on every screen.

grid.breakpoint.* holds the breakpoints, grid.container.* the width of the container at each breakpoint, grid.gutter.* the gutters, and grid.margin.* the margins of the page, each a size in design pixels. grid.columns.* holds the number of columns at each breakpoint, a number without a unit. The container of a step is narrower than the breakpoint of that step. The page gaps space.page.large-gap, space.page.medium-gap, and space.page.small-gap of the space tokens reference grid.gutter.medium.

Context tokens

size.context.* names evenly spaced steps of the scale by role, from 2xsmall to 2xlarge. Reach for them to size an element that has no component token.

TokenReference
size.context.2xlarge{size.unit.64}
size.context.xlarge{size.unit.56}
size.context.large{size.unit.48}
size.context.medium{size.unit.40}
size.context.small{size.unit.32}
size.context.xsmall{size.unit.24}
size.context.2xsmall{size.unit.16}

Icon sizes

size.icon.glyph.* names the sizes of an icon, from 3xsmall to 6xlarge. Most component tokens for an icon reference size.unit.* directly; size.dropdown.icon references size.icon.glyph.small.

TokenReference
size.icon.glyph.6xlarge{size.unit.64}
size.icon.glyph.5xlarge{size.unit.56}
size.icon.glyph.4xlarge{size.unit.48}
size.icon.glyph.3xlarge{size.unit.40}
size.icon.glyph.2xlarge{size.unit.36}
size.icon.glyph.xlarge{size.unit.32}
size.icon.glyph.large{size.unit.28}
size.icon.glyph.medium{size.unit.24}
size.icon.glyph.small{size.unit.20}
size.icon.glyph.xsmall{size.unit.16}
size.icon.glyph.2xsmall{size.unit.12}
size.icon.glyph.3xsmall{size.unit.8}

Asset sizes

size.asset.* holds the size of an indicator and of a separator. The border width tokens borderWidth.asset.indicator and borderWidth.asset.separator reference them.

TokenReference
size.asset.indicator{size.unit.4}
size.asset.separator{size.unit.1}

Component tokens

Component tokens hold the sizes of the parts of one component. A component with sizes has a token per size and part, size.<component>.<size>-<part>, in the source order medium, large, small. The part main is the component itself; parts like icon, caret, and avatar are elements inside it.

Accordion

Accordion sizes hold the indicator of each accordion size.

TokenReference
size.accordion.medium-indicator{size.unit.24}
size.accordion.large-indicator{size.unit.28}
size.accordion.small-indicator{size.unit.20}

Alert

Alert sizes hold the icon of the large and the small alert.

TokenReference
size.alert.large-icon{size.unit.40}
size.alert.small-icon{size.unit.40}

Badge

Badge sizes hold the badge and its icon for each badge size.

TokenReference
size.badge.medium-main{size.unit.24}
size.badge.medium-icon{size.unit.16}
size.badge.large-main{size.unit.28}
size.badge.large-icon{size.unit.20}
size.badge.small-main{size.unit.20}
size.badge.small-icon{size.unit.12}

Button

Button sizes hold the button, its icon, and its caret for each button size.

TokenReference
size.button.medium-main{size.unit.40}
size.button.medium-icon{size.unit.24}
size.button.medium-caret{size.unit.20}
size.button.large-main{size.unit.48}
size.button.large-icon{size.unit.28}
size.button.large-caret{size.unit.24}
size.button.small-main{size.unit.32}
size.button.small-icon{size.unit.20}
size.button.small-caret{size.unit.16}

Chip

Chip sizes hold the chip, its icon, and its avatar for each chip size.

TokenReference
size.chip.medium-main{size.unit.32}
size.chip.medium-icon{size.unit.20}
size.chip.medium-avatar{size.unit.24}
size.chip.large-main{size.unit.40}
size.chip.large-icon{size.unit.24}
size.chip.large-avatar{size.unit.32}
size.chip.small-main{size.unit.24}
size.chip.small-icon{size.unit.16}
size.chip.small-avatar{size.unit.20}

List

List sizes hold the icon, the image, and the disclosure of a list item.

TokenReference
size.list.icon{size.unit.24}
size.list.image{size.unit.40}
size.list.disclosure{size.unit.8}

Date picker

Date picker sizes hold the width and the height of a day, and the widths of a week and of a preset. The source computes the width of a week from the width of a day.

TokenReference
size.datepicker.day-width{size.unit.32}
size.datepicker.day-height{size.unit.32}
size.datepicker.week-width{size.datepicker.day-width}*7
size.datepicker.preset-width{size.unit.120}

Dropdown sizes hold the icon and the disclosure of a dropdown. The icon follows the icon sizes of the context level.

TokenReference
size.dropdown.icon{size.icon.glyph.small}
size.dropdown.disclosure{size.unit.16}

Form input

Form input sizes hold the icon and the caret of each input size. The group has no main token.

TokenReference
size.form-input.medium-icon{size.unit.20}
size.form-input.medium-caret{size.unit.20}
size.form-input.large-icon{size.unit.24}
size.form-input.large-caret{size.unit.24}
size.form-input.small-icon{size.unit.16}
size.form-input.small-caret{size.unit.16}

Modal sizes hold the width and the height of the modal window: size.modal.window-<size>-w and size.modal.window-<size>-h, for the sizes small, medium, large, and xlarge. These tokens hold a size of their own and reference no step of the scale.

Notification

Notification sizes hold the icon of a notification.

TokenReference
size.notification.icon{size.unit.28}

Navigation sizes hold the widths of the left navigation and the height of the top navigation. size.nav-left.width references the expanded width.

TokenReference
size.nav-left.width{size.nav-left.width-expanded}
size.nav-left.width-expanded{size.unit.256}
size.nav-left.width-collapsed{size.unit.72}
size.nav-top.height{size.unit.64}

Pagination

Pagination sizes hold the width (-w) and the height (-h) of a dot in its idle and its active state.

TokenReference
size.pagination.dot-idle-h{size.unit.8}
size.pagination.dot-idle-w{size.unit.8}
size.pagination.dot-active-h{size.unit.8}
size.pagination.dot-active-w{size.unit.16}

Segment

Segment sizes hold the segment and its icon for each segment size.

TokenReference
size.segment.medium-main{size.unit.32}
size.segment.medium-icon{size.unit.20}
size.segment.large-main{size.unit.40}
size.segment.large-icon{size.unit.24}
size.segment.small-main{size.unit.24}
size.segment.small-icon{size.unit.16}

Usage

Size tokens apply to the width and the height of an element. The level to use depends on how specific the element is.

Choosing a level

Use the most specific token that names the element, and go down a level only when none does:

  • Use a component token for the part that it names: size.button.medium-icon for the icon of a medium button.
  • Use size.icon.glyph.* for an icon and size.context.* for another element that has no component token.
  • Use size.unit.* when no context token holds the size. The unit scale has steps between and beyond those of the context scale.
  • Leave dimension.base.* to the token sets. It is in the output because the unit tokens reference it.

Size and space

A size token sets a width or a height; a space token sets a padding or a gap. size.unit.16 and space.unit.16 hold the same size, because both reference dimension.base.16. The context tokens of both categories reference size.unit.*, so a change to size.unit.16 changes size.context.2xsmall and space.context.medium.

Platform output

Size tokens print in rem on the web, as CGFloat points on iOS, and as dp dimension resources on Android.

PlatformNameFormat
Web$cx-size-context-mediumA size in rem
iOSSizeContextMediumA CGFloat in points
Android@dimen/size_context_mediumA <dimen> in dp

The web platform converts design pixels to rem at sixteen pixels per rem. iOS and Android keep the number of design pixels, as points and as dp.

The build writes every level with its resolved size, dimension.base.* included. The values in the examples are those of the token sets that init writes. In main.scss:

SCSS
$cx-dimension-base-16: 1rem !default;
$cx-size-unit-16: 1rem !default;
$cx-size-context-2xsmall: 1rem !default;

With the outputReferences option, a token names the token that it references, which is why dimension.base.* is in the output. The Style Dictionary guide describes the option. With it, the build writes in ChassisTokens.swift:

SWIFT
    public static let DimensionBase16 = CGFloat(16)
    public static let SizeUnit16 = DimensionBase16
    public static let SizeContext2xsmall = SizeUnit16

In a repository with screens, the main file of each platform holds the sizes of the first configured screen, and the number file of a screen, such as number-small.scss, holds the sizes of that screen.

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