Fluid Typography System

Dedicated fluid font sizes that scale smoothly between mobile and desktop

Using custom clamp() utilities separate from Tailwind's defaults

Fluid Heading Sizes

Perfect for display text, headers, and titles with dramatic scaling

Small Heading (text-heading-sm)
class="text-heading-sm" | 16px → 30px

Medium Heading (text-heading-md)

class="text-heading-md" | 20px → 40px

Large Heading (text-heading-lg)

class="text-heading-lg" | 30px → 50px

XL Heading (text-heading-xl)

class="text-heading-xl" | 40px → 60px

2XL Hero (text-heading-2xl)

class="text-heading-2xl" | 50px → 70px

Fluid Body Text Sizes

Subtle scaling for optimal readability across all screen sizes

Small body text for captions, footnotes, and secondary information. This size is perfect for supporting content that needs to be readable but not prominent.

class="text-body-sm" | 14px → 16px

Medium body text is the standard for most content. This provides excellent readability across all devices and is ideal for paragraphs, lists, and general content.

class="text-body-md" | 16px → 18px

Large body text works well for lead paragraphs, introductory content, or when you want to emphasize readability. This size commands attention while remaining comfortable to read.

class="text-body-lg" | 18px → 20px

Extra large body text is perfect for hero descriptions, important callouts, or when you want content to feel more impactful while maintaining body text characteristics.

class="text-body-xl" | 20px → 22px

2XL body text bridges the gap between body content and headings. Use this for prominent descriptions, large quotes, or featured content that needs to stand out.

class="text-body-2xl" | 22px → 24px

Complete Class Reference

Heading Classes

text-heading-sm 16px → 30px
text-heading-md 20px → 40px
text-heading-lg 30px → 50px
text-heading-xl 40px → 60px
text-heading-2xl 50px → 70px

Body Text Classes

text-body-sm 14px → 16px
text-body-md 16px → 18px
text-body-lg 18px → 20px
text-body-xl 20px → 22px
text-body-2xl 22px → 24px

Usage Recommendations

Heading Classes:
  • text-heading-sm: Small section headers
  • text-heading-md: Card titles, subsections
  • text-heading-lg: Page sections
  • text-heading-xl: Page titles
  • text-heading-2xl: Hero headlines
Body Classes:
  • text-body-sm: Captions, fine print
  • text-body-md: Standard paragraphs
  • text-body-lg: Lead paragraphs
  • text-body-xl: Hero descriptions
  • text-body-2xl: Featured quotes

Technical Implementation

Our fluid typography system uses CSS clamp() functions with mathematically calculated values to create perfect linear scaling between viewports.

This approach keeps Tailwind's standard classes (text-base, text-lg, etc.) unchanged while providing dedicated fluid classes for responsive typography.

Understanding clamp() Syntax

clamp(minimum, preferred, maximum)
Minimum:
Font size at mobile (360px)
Preferred:
Fluid calculation that scales
Maximum:
Font size at desktop (1920px)

Mathematical Formula

The middle "preferred" value creates linear interpolation between two viewport sizes:

Step 1: Calculate the scaling coefficient
coefficient = (max_font - min_font) ÷ (max_viewport - min_viewport) × 100
Step 2: Calculate the base value
base = min_font - (coefficient × min_viewport ÷ 100)
Result: Perfect linear scaling
clamp(min_font, base + coefficient×vw, max_font)

Concrete Example: text-heading-lg

Our Target:
  • Mobile (360px): 30px font size
  • Desktop (1920px): 50px font size
  • Viewport difference: 1560px
  • Font difference: 20px
Calculation:
Coefficient:
20px ÷ 1560px × 100 = 1.2821vw
Base:
30px - (1.2821 × 360px ÷ 100) = 1.5865rem
clamp(1.875rem, 1.5865rem + 1.2821vw, 3.125rem)

This creates perfect linear scaling: at 360px viewport = 30px font, at 1920px viewport = 50px font

Why This Approach Works

Mathematical Benefits:
  • • Perfect linear interpolation
  • • Predictable scaling at any viewport
  • • No sudden jumps or awkward sizes
  • • Browser-optimized performance
Development Benefits:
  • • Separate from Tailwind defaults
  • • Easily maintainable variables
  • • Documented calculation process
  • • Extensible for new sizes

Pro Tip: Testing Your Calculations

You can verify the math works by checking the computed font size at your target viewports using browser dev tools. At 360px width, you should see exactly your minimum size, and at 1920px width, exactly your maximum size.

Test the Scaling

Resize your browser window to see how the text scales smoothly!

Hero Headline

Section Title

This is hero description text that scales fluidly as you resize the browser window.

Standard paragraph text maintains perfect readability at all sizes while scaling subtly.

Small supporting text for captions or additional information.