• Docs
  • Components
  • Blocks
  • Admin
CtrlK
Get Started
  • Introduction
  • Setup
  • CLI
  • VS Code Extension
  • Figma Code Connect
  • MCP Server
  • llms.txt
  • Changelog
Foundations
  • Design Tokens
  • Theming & Modes
  • Semantic Colors
  • Spacing
  • Typography
Testing
  • Test Guide
  • Performance Tests
  • Visual Regression
Components
  • Accordion
  • Activity Feed
  • Alert
  • Avatar
  • Badge
  • Breadcrumbs
  • Button
  • Card
  • Carousel
  • Checkbox
  • Collapsible
  • Combobox
  • Command Palette
  • Context Menu
  • Date Picker
  • Dialog
  • Dropdown Menu
  • File Upload
  • Hover Card
  • Input
  • Kbd
  • Label
  • Menubar
  • Metric Card
  • Multi Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Quick Actions
  • Radio
  • Rating
  • Resizable
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Skeleton
  • Slider
  • Spinner
  • Split Button
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Textarea
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree View
Blocks
  • Activity Feed
  • App Shell
  • Authentication Block
  • Benefits Section
  • Cta Section
  • Data Table
  • Empty State
  • Faq Section
  • Feature Grid Section
  • Footer Section
  • Hero Section
  • Kpi Dashboard
  • Kpi Strip
  • Link Card
  • Metric Card
  • Navigation Header
  • Pagination Footer
  • Pricing Table
  • Quick Actions
  • Settings Screen
Resources
  • API Reference
SpacingTest Guide

Typography

Typography tokens for consistent text across the design system.

Font Families

Fragment UI uses Geist as the primary font family with system fallbacks. The typography system supports both sans-serif and monospace fonts.

--typography-font-sansGeist, ui-sans-serif, system-ui, sans-serif
The quick brown fox jumps over the lazy dog
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789 !@#$%^&*()
--typography-font-monoui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace
const fragment = "design system";
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789 !@#$%^&*()

Font Sizes

The typography system provides a font-size scale driven by tokens:

--typography-size-xs12px
The quick brown fox jumps over the lazy dog (12px)
--typography-size-intro15px
The quick brown fox jumps over the lazy dog (15px)
--typography-size-sm14px
The quick brown fox jumps over the lazy dog (14px)
--typography-size-md16px
The quick brown fox jumps over the lazy dog (16px)
--typography-size-lg18px
The quick brown fox jumps over the lazy dog (18px)
--typography-size-xl20px
The quick brown fox jumps over the lazy dog (20px)
--typography-size-2xl22px
The quick brown fox jumps over the lazy dog (22px)

Font Weights

Fragment UI supports five font weights for different text hierarchies and emphasis:

--typography-weight-lightLight
The quick brown fox jumps over the lazy dog
--typography-weight-regularRegular
The quick brown fox jumps over the lazy dog
--typography-weight-mediumMedium
The quick brown fox jumps over the lazy dog
--typography-weight-semiboldSemibold
The quick brown fox jumps over the lazy dog
--typography-weight-boldBold
The quick brown fox jumps over the lazy dog

Display Styles

Large display text styles for headings and hero sections. These styles use tighter line heights and negative letter spacing for impact.

Display 2xltext-display-2xl
Size: 72px
Line height: 110%
Letter spacing: -1.44px
Display 2xl
Display xltext-display-xl
Size: 60px
Line height: 110%
Letter spacing: -1.2px
Display xl
Display lgtext-display-lg
Size: 48px
Line height: 110%
Letter spacing: -0.96px
Display lg
Display mdtext-display-md
Size: 36px
Line height: 110%
Letter spacing: -0.72px
Display md
Display smtext-display-sm
Size: 24px
Line height: 110%
Display sm
Display xstext-display-xs
Size: 20px
Line height: 110%
Display xs

Text Styles

Body text styles for paragraphs and content. These styles use comfortable line heights for readability.

Text 2xltext-2xl
Size: 22px • Line height: 150%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text 2xl style.
Text xltext-xl
Size: 20px • Line height: 150%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text xl style.
Text lgtext-lg
Size: 18px • Line height: 150%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text lg style.
Text mdtext-md
Size: 16px • Line height: 160%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text md style.
Text introtext-intro
Size: 15px • Line height: 160%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text intro style.
Text smtext-sm
Size: 14px • Line height: 160%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text sm style.
Text xstext-xs
Size: 12px • Line height: 160%
The quick brown fox jumps over the lazy dog. This is sample text to demonstrate the text xs style.

Semantic elements

In Fragment UI docs, semantic HTML elements (headings, paragraphs, lists, inline code, strong/emphasis) are styled by DocumentContent using DS typography tokens. This avoids duplicating (and potentially drifting) hardcoded values in the documentation.

Lists

List styles for ordered and unordered lists:

Unordered List

  • First item in the list
  • Second item with more content to demonstrate wrapping
  • Third item
  • Fourth item

Ordered List

  1. First numbered item
  2. Second numbered item
  3. Third numbered item
  4. Fourth numbered item

Code & Monospace

Monospace font styles for code blocks and inline code:

Inline Code

Use inline code for short code snippets within paragraphs.

Code Block

const fragment = "design system";
const tokens = { typography: "system" };
console.log(fragment, tokens);

Usage Examples

Here are practical examples of how to use typography tokens and styles in your components:

CSS Variables

/* Font families */
font-family: var(--typography-font-sans);
font-family: var(--typography-font-mono);

/* Font sizes */
font-size: var(--typography-size-xs); /* 12px */
font-size: var(--typography-size-intro); /* 15px */
font-size: var(--typography-size-sm); /* 14px */
font-size: var(--typography-size-md); /* 16px */
font-size: var(--typography-size-lg); /* 18px */
font-size: var(--typography-size-xl); /* 20px */
font-size: var(--typography-size-2xl); /* 22px */

/* Using with density multipliers */
font-size: calc(var(--typography-size-md) * var(--density-typography-size-multiplier));

Tailwind Classes

Note: Tailwind utilities like text-xs are fixed rem-based sizes. If you want typography to be driven by design tokens (and respond to Theme Builder / density), prefer text-[length:var(--typography-size-*)] (or inline styles with var(--typography-size-*)).

/* Display styles */
<h1 className="text-display-2xl">Display Heading</h1>
<h2 className="text-display-xl">Large Display</h2>

/* Text styles */
<p className="text-[length:var(--typography-size-lg)]">Large text</p>
<p className="text-[length:var(--typography-size-md)]">Medium text</p>
<p className="text-[length:var(--typography-size-sm)]">Small text</p>
<p className="text-[length:var(--typography-size-xs)]">Extra small text</p>

/* Font weights */
<p className="font-light">Light (300)</p>
<p className="font-normal">Regular (400)</p>
<p className="font-medium">Medium (500)</p>
<p className="font-semibold">Semibold (600)</p>
<p className="font-bold">Bold (700)</p>

/* Font families */
<p className="font-sans">Sans-serif text</p>
<code className="font-mono">Monospace code</code>

React Components

import { cn } from "@/lib/utils";

// Display heading
<h1 
  className={cn(
    "text-display-lg",
    "font-medium",
    "text-[color:var(--foreground-primary)]"
  )}
>
  Hero Title
</h1>

// Body text
<p 
  style={{
    fontFamily: "Geist, sans-serif",
    fontSize: "var(--typography-size-md)",
    fontWeight: 300,
    lineHeight: "160%",
  }}
>
  Body text content
</p>

// Code block
<pre className="font-mono text-[length:var(--typography-size-sm)] bg-[color:var(--color-surface-2)] p-[var(--space-4)] rounded-[var(--radius-md)]">
  <code>const code = "example";</code>
</pre>

Best Practices

  • Use semantic HTML: Always use proper heading tags (h1-h6) instead of styled divs for accessibility
  • Maintain hierarchy: Use heading levels in order (h1 → h2 → h3) without skipping levels
  • Limit display styles: Use display styles sparingly for hero sections and major headings only
  • Consistent line heights: Use the predefined line heights (110% for display, 150-160% for text) for optimal readability
  • Font weights: Use medium (500) for headings and light (300) for body text to maintain visual hierarchy
  • Responsive typography: Consider using smaller font sizes on mobile devices
  • Density modes: Typography scales automatically with density modes (compact, normal, comfortable)

Density Modes

Typography scales automatically with density modes. See Density documentation for more details on how typography adapts to different density settings.

Density Typography Multipliers

  • Compact: 0.875x size multiplier, 1.3 line height
  • Normal: 1x size multiplier, 1.5 line height
  • Comfortable: 1.125x size multiplier, 1.7 line height
SpacingTest Guide