Skip to content

Design tokens / Typography

Typography ​

Typography carries hierarchy. Every piece of text should use one of these tokens according to its importance — never a free-form font-size.

Defined in packages/pixel/tokens/fontSize.css, lineHeight.css, fontFamily.css and fontWeight.css.

Font size ​

TokenValueSample
--font-size-xxxs12pxAg
--font-size-xxs14pxAg
--font-size-xs16pxAg
--font-size-sm20pxAg
--font-size-md24pxAg
--font-size-lg32pxAg
--font-size-xl40pxAg
--font-size-xxl48pxAg
--font-size-xxxl64pxAg
--font-size-display80pxAg
--font-size-giant96pxAg

<kb-text>, <kb-label> and <kb-icon> resolve their size attribute against this scale, which is why an icon sized like the text beside it lines up with it.

preview
Code
html
<kb-stack direction="column" spacing="quarck" align="start">
  <kb-text size="xxxs">xxxs — captions and metadata</kb-text>
  <kb-text size="xxs">xxs — the default body size</kb-text>
  <kb-text size="xs">xs — comfortable body copy</kb-text>
  <kb-text size="md">md — a component title</kb-text>
</kb-stack>

Line height ​

TokenValue
--line-height-default100%
--line-height-xs115%
--line-height-sm120%
--line-height-md133%
--line-height-lg150%
--line-height-xl170%
--line-height-xxl200%

Tighter values suit large display type, where 100% keeps a headline compact. Body copy wants lg or xl — the larger the measure, the more leading it needs to stay readable.

Font family ​

TokenValue
--font-family-base"Roboto", sans-serif
--font-family-highlight"Roboto Condensed", sans-serif

base is the default body family; highlight is reserved for headings and emphasis. Swapping these two tokens is enough to give a brand a different typographic voice without touching a single component.

!> The families are named, not bundled. Neither font ships with the package — load them yourself (Google Fonts, a self-hosted @font-face), or override the tokens with families you already serve. Without that, the browser falls back to sans-serif.

Font weight ​

TokenValueSample
--font-weight-regular400The quick brown fox
--font-weight-medium500The quick brown fox
--font-weight-bold700The quick brown fox

Three steps, on purpose. medium is what separates a <kb-label> from a <kb-helper> at the same size — enough contrast to read as a label, not enough to read as a heading.