Skip to content

Typography

This component provides comprehensive typography styling and utility classes for Metro UI.

The typography component defines CSS classes and styles for controlling text appearance, including font sizes, weights, alignments, transformations, and special text elements. These utilities help create consistent typography throughout your application.

VariableDefault ValueDescription
--h1-size2remFont size for h1 headings
--h2-size1.5remFont size for h2 headings
--h3-size1.25remFont size for h3 headings
--h4-size1remFont size for h4 headings
--h5-size0.875remFont size for h5 headings
--h6-size0.75remFont size for h6 headings
VariableDefault ValueDescription
--base-text-weight-ultralight100Ultralight font weight
--base-text-weight-light300Light font weight
--base-text-weight-normal400Normal font weight
--base-text-weight-medium500Medium font weight
--base-text-weight-semibold600Semibold font weight
VariableLight ThemeDark ThemeDescription
--mark-background#a6d2ff#c0c0c0Background color for <mark> elements
--mark-color#191919#000000Text color for <mark> elements
--code-background#99a1b31a#2b2d30Background color for <code> elements
--code-color#191919#b3b3aaText color for <code> elements
--kbd-background#004D6FFF#004D6FFFBackground color for <kbd> elements
--kbd-color#ffffff#ffffffText color for <kbd> elements
ClassDescription
.text-ultralightSets font weight to ultralight (100)
.text-lightSets font weight to light (300)
.text-normalSets font weight to normal (400)
.text-mediumSets font weight to medium (500)
.text-boldSets font weight to semibold (600)
ClassDescription
.text-weight-1Sets font weight to 100
.text-weight-2Sets font weight to 200
.text-weight-3Sets font weight to 300
.text-weight-4Sets font weight to 400
.text-weight-5Sets font weight to 500
.text-weight-6Sets font weight to 600
.text-weight-7Sets font weight to 700
.text-weight-8Sets font weight to 800
.text-weight-9Sets font weight to 900
.text-weight-10Sets font weight to 1000

Large, eye-catching text styles for hero sections and major headings:

ClassFont SizeFont Weight
.display4112px200
.display356px400
.display248px400
.display136px400

Standard heading styles that can be applied to any element:

ClassFont SizeFont Weight
.h1, h12rem600
.h2, h21.5rem600
.h3, h31.25rem600
.h4, h41rem600
.h5, h50.875rem600
.h6, h60.75rem600

Additional heading styles with specific sizes and weights:

ClassFont SizeFont Weight
.leader48px300
.sub-leader38px400
.header30px500
.sub-header24px500
.alt-header20px500
.sub-alt-header16px500
ClassFont SizeFont WeightDescription
.text-small12px400Small text
.text-secondary14px400Secondary text
.text-leader24px300Large lead paragraph text with increased line height
.text-leader220px300Medium lead paragraph text with increased line height
.text-muted--Text with muted color (uses --body-color-secondary)
ClassDescription
.text-upperTransforms text to uppercase
.text-lowerTransforms text to lowercase
.text-capCapitalizes the first letter of each word
ClassDescription
.text-leftAligns text to the left
.text-rightAligns text to the right
.text-centerCenters text
.text-justJustifies text
.text-ellipsisTruncates text with an ellipsis when it overflows
ClassDescription
.text-italicApplies italic style
.text-obliqueApplies oblique style
.text-overlineAdds a line above the text
.text-linethroughAdds a line through the text
.text-underlineAdds a line below the text
.text-underoverAdds lines both above and below the text
.no-decorRemoves text decoration
ClassDescription
.va-topAligns to the top
.va-bottomAligns to the bottom
.va-baselineAligns to the baseline
.va-middleAligns to the middle
.va-subAligns as subscript
.va-superAligns as superscript
.va-text-topAligns to the text top
.va-text-bottomAligns to the text bottom
ClassDescription
.reduce-1Reduces font size to 0.9em
.reduce-2Reduces font size to 0.8em
.reduce-3Reduces font size to 0.7em
.reduce-4Reduces font size to 0.6em
.reduce-5Reduces font size to 0.5em
.reduce-6Reduces font size to 0.4em
.reduce-7Reduces font size to 0.3em
.reduce-8Reduces font size to 0.2em
.reduce-9Reduces font size to 0.1em
ClassDescription
.enlargeSets font size to 1em
.enlarge-1Enlarges font size to 1.1em
.enlarge-2Enlarges font size to 1.2em
.enlarge-3Enlarges font size to 1.3em
.enlarge-4Enlarges font size to 1.4em
.enlarge-5Enlarges font size to 1.5em
.enlarge-6Enlarges font size to 1.6em
.enlarge-7Enlarges font size to 1.7em
.enlarge-8Enlarges font size to 1.8em
.enlarge-9Enlarges font size to 1.9em
.enlarge-2xEnlarges font size to 2em
.enlarge-3xEnlarges font size to 3em
.enlarge-4xEnlarges font size to 4em
ClassDescription
.wrap-longForces long words to break and wrap
.errorAdds a red wavy underline to indicate an error
.monoSets font to monospace
.indentIndents the first line of text
.indent-letterCreates a drop cap effect (enlarged first letter)

The file also provides styling for various HTML text elements:

Links are styled with:

  • Color: --link-color
  • No text decoration by default
  • Hover color: --link-color-hover
  • Hover text decoration: underline

Abbreviations are styled with:

  • No text decoration
  • Dotted bottom border
  • Help cursor

Code elements are styled with:

  • Monospace font
  • 13px font size
  • Specific background and text colors
  • Rounded corners
  • Padding for inline code and kbd elements

Highlighted text is styled with:

  • Background color: --mark-background
  • Text color: --mark-color
  • Small padding

Blockquotes are styled with:

  • Left border
  • Padding
  • Special styling for the .right-side variant with right border

Horizontal rules are styled with:

  • Color: --border-color
  • Height: 2px (default), 1px (.thin), or 3px (.fat)

Many typography utilities have responsive variants that apply at specific breakpoints. The responsive variants follow the naming pattern .{class}-{breakpoint}.

For example:

  • .text-center-md - Centers text on medium screens and above
  • .text-upper-lg - Transforms text to uppercase on large screens and above
  • .enlarge-2-xl - Enlarges font size to 1.2em on extra large screens and above

Where {breakpoint} can be: xs, sm, md, lg, xl, xxl, xxxl

<!-- Display text for hero sections -->
<h1 class="display3">Welcome to Our Site</h1>
<!-- Standard headings -->
<h1>Heading Level 1</h1>
<h2>Heading Level 2</h2>
<!-- Heading classes applied to non-heading elements -->
<div class="h3">This looks like an h3</div>
<!-- Alternative heading styles -->
<div class="leader">Large Leader Text</div>
<div class="sub-leader">Slightly Smaller Leader</div>
<!-- Font weights -->
<p class="text-light">Light weight text</p>
<p class="text-bold">Bold text</p>
<p class="text-weight-7">Very bold text (700)</p>
<!-- Text styles -->
<p class="text-italic">Italic text</p>
<p class="text-underline">Underlined text</p>
<!-- Text transformations -->
<p class="text-upper">This will be uppercase</p>
<p class="text-cap">This will capitalize each word</p>
<!-- Text alignment -->
<p class="text-left">Left-aligned text</p>
<p class="text-center">Centered text</p>
<p class="text-right">Right-aligned text</p>
<!-- Responsive alignment -->
<p class="text-center text-left-md">
Centered on small screens, left-aligned on medium screens and above
</p>
<!-- Code and keyboard elements -->
<p>Use the <code>console.log()</code> method to debug.</p>
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.</p>
<!-- Marked text -->
<p>This is <mark>highlighted</mark> text.</p>
<!-- Blockquote -->
<blockquote>
This is a blockquote.
<small>- Author Name</small>
</blockquote>
<!-- Right-aligned blockquote -->
<blockquote class="right-side">
This is a right-aligned quote.
<small>Author Name</small>
</blockquote>
<!-- Reducing font size -->
<p>Normal text with <span class="reduce-2">smaller text</span> inside.</p>
<!-- Enlarging font size -->
<p>Normal text with <span class="enlarge-2">larger text</span> inside.</p>
<!-- Very large text -->
<span class="enlarge-3x">3x Larger</span>
  1. Consistent Headings: Use the standard heading classes (h1-h6 or .h1-.h6) for document structure and SEO.

  2. Responsive Typography: Use responsive variants to adjust text alignment and size based on screen size.

  3. Semantic HTML: Use the appropriate HTML elements (<code>, <kbd>, <mark>, etc.) with these utility classes for better accessibility.

  4. Font Size Modifiers: Use relative size modifiers (.reduce-*, .enlarge-*) rather than fixed sizes to maintain proper scaling.

  5. Text Wrapping: Use .wrap-long for content that might contain very long words or URLs to prevent layout issues.

  6. Vertical Rhythm: Maintain consistent spacing between text elements for better readability.