Skip to main content

Typography

The design system provides a consistent typographic scale that balances readability with visual hierarchy. All typography is defined using CSS custom properties for flexibility and maintainability.

Font Family​

The system uses the system font stack for optimal performance and native feel across platforms:

--font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans',
'Helvetica Neue', sans-serif;

This font stack provides:

  • Native look on macOS and iOS (San Francisco)
  • Native look on Windows (Segoe UI)
  • Roboto on Android
  • Fallbacks for other systems

Font Sizes​

TokenSizeUse Case
--font-size-xs12pxSmall text, captions, labels
--font-size-sm14pxHelper text, form labels
--font-size-md16pxBody text, paragraph content
--font-size-lg18pxSubheadings, section titles
--font-size-xl20pxPage headings
--font-size-2xl24pxMajor headings
--font-size-3xl32pxHero headlines

Font Weights​

TokenWeightUse Case
--font-weight-light300Decorative headers
--font-weight-normal400Body text
--font-weight-medium500Labels, buttons
--font-weight-semibold600Subheadings
--font-weight-bold700Headings

Line Heights​

TokenValueUse Case
--line-height-tight1.2Headings
--line-height-normal1.5Body text (optimal for readability)
--line-height-relaxed1.75Long-form content

Typographic Scale​

<h1 style="font-size: var(--font-size-3xl); font-weight: var(--font-weight-bold);">
Headline
</h1>

<h2 style="font-size: var(--font-size-2xl); font-weight: var(--font-weight-semibold);">
Subheading
</h2>

<p style="font-size: var(--font-size-md); line-height: var(--line-height-normal);">
Body text with optimal readability.
</p>

<small style="font-size: var(--font-size-sm); color: var(--color-gray-600);">
Helper text or captions
</small>

Usage​

Import the tokens file and use the CSS variables:

@import "@milfushi/ui/dist/tokens.css";

.heading {
font-family: var(--font-family-base);
font-size: var(--font-size-2xl);
font-weight: var(--font-weight-bold);
line-height: var(--line-height-tight);
}

.body {
font-family: var(--font-family-base);
font-size: var(--font-size-md);
font-weight: var(--font-weight-normal);
line-height: var(--line-height-normal);
}

Accessibility​

  • Line height of at least 1.5 for body text ensures readability
  • Font size of at least 16px improves mobile readability and prevents auto-zoom
  • High contrast between text and background (WCAG AA standard)
  • Clear visual hierarchy helps users navigate content