Typography System
This project uses a token-driven typography system built with SCSS maps and CSS variables. You define a token once — size, line-height, breakpoints — and the system generates the utility class, the CSS variable, and all responsive overrides from that single definition.
Overview
Section titled “Overview”The typography setup has three parts:
- Typography tokens — Define font sizes, line-heights, letter-spacing
- CSS variables & classes — Generated from tokens
- Mixins — For custom applications
Fonts are defined as CSS variables for flexibility:
$font-inter: var(--font-inter);$base-font-family: $font-inter;Typography Tokens
Section titled “Typography Tokens”$type-tokens: ( display: ( lg: ( size: rem(48px), line-height: 1.1, letter-spacing: -0.001em, breakpoint: ( tablet: ( size: rem(28px), ), mobile: ( size: rem(24px), ), ), ), ),);$type-tokens is the single source of truth for all typography in the project. Every utility class, CSS variable, and responsive override is generated from this map — you never write the same font size in two places.
Token Structure
Section titled “Token Structure”group: size: size: font-size (required) line-height: line-height (optional) letter-spacing: letter-spacing (optional) breakpoint: (optional) breakpoint-name: size: override font-sizeGroups
Section titled “Groups”Top-level keys are semantic groups:
display— Hero titles, very large textheading— Page and section headingsbody— Body text, paragraphs
Available Typography Classes
Section titled “Available Typography Classes”.text-display-lg // Hero titles.text-display-md // Section headers.text-heading-lg // Page headings.text-heading-md // Section headings.text-heading-sm // Subsection headings.text-body-lg // Large body text.text-body-md // Standard body text.text-body-sm // Small text, captions.text-body-xs // Very small textHTML Classes
Section titled “HTML Classes”<h1 class="text-display-lg">Page Title</h1><p class="text-body-md">Body text here</p>SCSS Mixins
Section titled “SCSS Mixins”.card__title { @include typography(heading, lg);}Mixin options:
@include typography(heading, lg); // Base styles only@include typography(heading, lg, mobile); // Specific breakpoint@include typography-with-breakpoints(heading, lg); // All breakpointsResponsive Typography
Section titled “Responsive Typography”Breakpoints are defined in the token and automatically applied:
display: ( lg: ( size: rem(48px), breakpoint: ( tablet: ( size: rem(32px), ), mobile: ( size: rem(24px), ), ), ));This generates responsive CSS variables and utility classes automatically.
Font Weights
Section titled “Font Weights”Defined separately in $font-weights:
$font-weights: ( light: 300, normal: 400, medium: 500, bold: 700,);Usage:
<p class="text-body-md font-medium">Medium text</p>Generated CSS Variables
Section titled “Generated CSS Variables”:root { --instance-display-lg-font-size: 3rem; --instance-display-lg-line-height: 1.1; --instance-display-lg-tablet-font-size: 1.75rem; --instance-display-lg-mobile-font-size: 1.5rem;}All tokens generate CSS variables on :root automatically — you never write these by hand. The naming pattern is --instance-{group}-{size}-{property}.
One-off Overrides
Section titled “One-off Overrides”.custom-heading { --instance-heading-lg-font-size: 2.25rem;}Override a token locally by redefining its CSS variable on a specific selector. The utility class picks up the new value without needing a new token or a specificity battle.
Adding New Tokens
Section titled “Adding New Tokens”-
Open the token file
Edit
src/styles/abstracts/variables/_typography.scss. -
Add your token
$type-tokens: (display: (xl: (size: rem(64px),line-height: 1.1,letter-spacing: -0.002em,breakpoint: (tablet: (size: rem(48px),),mobile: (size: rem(36px),),),),),); -
Use the generated class or mixin
<h1 class="text-display-xl">Hero Title</h1>or via SCSS:
.hero__title {@include typography-with-breakpoints(display, xl);}
From Figma
Section titled “From Figma”Designer provided a type scale
Section titled “Designer provided a type scale”- Open the Typography / Type Scale board in Figma
- Copy font sizes, line heights, letter spacing, and weights
- Map into
$type-tokensusing semantic naming (display,heading,body+lg/md/sm)
No type scale board
Section titled “No type scale board”- Go page by page and collect typography styles
- Identify repeating patterns
- Map into
$type-tokenssemantically - Add even one-off sizes as tokens for consistency
Debugging
Section titled “Debugging”Enable debug output to see generated classes:
$font-output-generated-class-names: true;This prints generated class names to the SCSS output during compilation.