Typography

Use typography to present your design and content as clearly and efficiently as possible.

Syntax

Use semantic headings for document structure, then combine typography utilities to adjust their appearance. Start with .text-{size} for font size, .line-height-{effect} for line spacing and .letter-spacing-{effect} for tracking. Only font-size utilities have breakpoint variants: .text-{breakpoint}-{size}.

HTML
<h2 class="text-xl line-height-tight">Project overview</h2>
<p class="text-md line-height-relaxed">Keep your team's updates in one place.</p>

Class and token reference

The default Sass fontSizes map generates the following classes and tokens. Change the Sass map to configure the generated scale, or override a CSS token on an ancestor or element to change its value at runtime.

Class Font-size token
.text-xs --font-size-xs
.text-sm --font-size-sm
.text-md --font-size-md
.text-lg --font-size-lg
.text-xl --font-size-xl
.text-xxl --font-size-xxl
.text-xxxl --font-size-xxxl

The reference below covers headings, line height, text transform, letter spacing, alignment and wrapping. For text colors, see Colors.

Default

The examples use heading utility classes so the documentation page keeps a single, consistent heading hierarchy. Use the matching semantic heading element in application content.

h1 heading

h2 heading

h3 heading

h4 heading

h5 heading

h6 heading

Your workspace is ready.

small text bold text View typography documentation
HTML
<h1>h1 heading</h1>
<h2>h2 heading</h2>
<h3>h3 heading</h3>
<h4>h4 heading</h4>
<h5>h5 heading</h5>
<h6>h6 heading</h6>
<p>Your workspace is ready.</p>
<small>small text</small>
<b>bold text</b>
<a href="https://css-utils.oardi.com">View typography documentation</a>

Links use the semantic action foregrounds by default. Override the global --action-color* tokens for an application-wide palette or the link tokens on an ancestor for a local treatment.

CSS
--link-text-color: var(--action-color);
--link-hover-color: var(--action-color-hover);
--link-active-color: var(--action-color-active);
--link-focus-outline-width: var(--focus-outline-width);
--link-focus-outline-style: var(--focus-outline-style);
--link-focus-outline-color: var(--focus-outline-color);

Text scales

paragraph with .text-xs

paragraph with .text-sm

paragraph with .text-md

paragraph with .text-lg

paragraph with .text-xl

paragraph with .text-xxl

paragraph with .text-xxxl

HTML
<p class="text-xs">paragraph with .text-xs</p>
<p class="text-sm">paragraph with .text-sm</p>
<p class="text-md">paragraph with .text-md</p>
<p class="text-lg">paragraph with .text-lg</p>
<p class="text-xl">paragraph with .text-xl</p>
<p class="text-xxl">paragraph with .text-xxl</p>
<p class="text-xxxl">paragraph with .text-xxxl</p>

Line height

Use line-height utilities to adjust the vertical spacing within text. Each utility uses its corresponding --line-height-* design token.

Text with .line-height-none uses a line height of 1.
The lines sit tightly together.

Text with .line-height-tight uses a line height of 1.125.
The lines have compact spacing.

Text with .line-height-snug uses a line height of 1.25.
The lines remain moderately compact.

Text with .line-height-normal uses a line height of 1.5.
The lines have balanced spacing.

Text with .line-height-relaxed uses a line height of 1.75.
The lines have relaxed spacing.

Text with .line-height-loose uses a line height of 2.
The lines have generous spacing.

Text with .line-height-extra-loose uses a line height of 2.5.
The lines have the widest spacing.

HTML
<p class="line-height-none">Line height 1</p>
<p class="line-height-tight">Line height 1.125</p>
<p class="line-height-snug">Line height 1.25</p>
<p class="line-height-normal">Line height 1.5</p>
<p class="line-height-relaxed">Line height 1.75</p>
<p class="line-height-loose">Line height 2</p>
<p class="line-height-extra-loose">Line height 2.5</p>

Version 1.0.0 removed the .lh-* classes and their size-based --line-height-* tokens. When upgrading from 0.x, replace them with the corresponding effect names:

Removed classReplacement
.lh-xs.line-height-none
.lh-sm.line-height-tight
.lh-md.line-height-snug
.lh-lg.line-height-normal
.lh-xl.line-height-relaxed
.lh-xxl.line-height-loose
.lh-xxxl.line-height-extra-loose

Use the replacement’s suffix for its CSS token, for example --line-height-tight instead of --line-height-sm. The global --line-height token is unchanged. Range Slider marks, Stepper labels/status and Skeleton text placeholders now use --line-height-tight.

The Sass lineHeights map now uses effect names directly. Rename overrides such as sm: 1.2 to tight: 1.2, including keys accessed through map.get() in application Sass. The intermediate $line-height-effect-names map has been removed. Configure the theme before importing the library:

SCSS
@use '@oardi/css-utils/theme' with (
	$theme: (
		lineHeights: (
			tight: 1.2,
			compact: 1.1,
		),
	)
);
@use '@oardi/css-utils';

This overrides --line-height-tight and adds --line-height-compact with a .line-height-compact utility. Other default effects are retained. You can also override tokens at runtime, for example style="--line-height-tight: 1.2" on a component. Old size keys no longer configure the corresponding effect.

Text transform

Use .text-uppercase to display text in uppercase without changing the text content.

Uppercase text

HTML
<p class="text-uppercase">Uppercase text</p>

Letter spacing

Use effect-based letter-spacing utilities to tighten or widen text. Their relative values scale with the current font size, and each utility uses its corresponding --letter-spacing-* design token.

Class Letter spacing
.letter-spacing-tight -0.025em
.letter-spacing-normal 0
.letter-spacing-wide 0.025em
.letter-spacing-wider 0.05em
.letter-spacing-widest 0.1em

Text with .letter-spacing-tight

Text with .letter-spacing-normal

Text with .letter-spacing-wide

Text with .letter-spacing-wider

Text with .letter-spacing-widest

HTML
<p class="text-uppercase letter-spacing-wide">Uppercase text with wide letter spacing</p>

Version 1.0.0 removed .letter-space-0 through .letter-space-5 and the text module’s $letterSpacings list. The Sass theme’s letterSpacings map remains supported. With the default theme, .letter-space-0 becomes .letter-spacing-normal; choose other effects deliberately because their relative values are not visual aliases for the old 1px through 5px scale.

To retain a pixel value, add a custom theme key such as letterSpacings: (label: 2px) before importing the library; this generates .letter-spacing-label and --letter-spacing-label. For a local override, set style="--letter-spacing-wide: 2px" on an element using .letter-spacing-wide. Review the result at different font sizes when switching to the relative defaults.

Text alignment

Use .text-start and .text-end for alignment that follows the text direction, or .text-center for centered text.

Start aligned text.

Center aligned text.

End aligned text.

HTML
<p class="text-start">Start aligned text.</p>
<p class="text-center">Center aligned text.</p>
<p class="text-end">End aligned text.</p>

Text wrapping

Use overflow-wrap utilities to control how otherwise unbreakable text, such as long URLs, behaves when it reaches the edge of its container.

Class Behavior
.overflow-wrap-normal Keeps the browser's default wrapping behavior.
.overflow-wrap-break-word Breaks an unbreakable string when it would otherwise overflow.
.overflow-wrap-anywhere Allows a break at any point to prevent overflow.

https://example.com/a-very-long-path-without-any-natural-wrap-opportunities-that-stays-inside-its-container

HTML
<p class="overflow-wrap-anywhere">A-very-long-unbreakable-string</p>

Responsive text sizes

Use .text-{breakpoint}-{size} to change font size from a breakpoint upward. Combine it with a base .text-{size} class for smaller screens. Both forms use the existing --font-size-{size} tokens.

Sizes: xs, sm, md, lg, xl, xxl, xxxl.

BreakpointMinimum viewport width
sm576px
md768px
lg992px
xl1200px
xxl1400px

When several breakpoints apply, the larger breakpoint wins regardless of class order in the HTML. Sass theme overrides of fontSizes and breakpoints also apply to these utilities; override --font-size-{size} on an ancestor or element to customize a size at runtime.

Responsive sizing is opt-in: unmodified text sizes, semantic headings and the root font size stay unchanged. Sizes switch at breakpoints without automatic fluid scaling. Keep semantic heading levels appropriate to the content, even when changing their visual size.

Recipes

Responsive page heading

Keep the heading level appropriate to the document while increasing its visual size on larger screens. This heading uses xl below 768px, xxl from 768px and xxxl from 992px.

Project overview

HTML
<h2 class="text-xl text-md-xxl text-lg-xxxl line-height-tight">Project overview</h2>

The preview uses a paragraph to preserve this documentation page’s heading hierarchy.

Long text in a flex layout

Flex and grid items use an intrinsic minimum width by default. Add .min-w-0 to an item that needs to shrink, then use .overflow-wrap-anywhere to keep long URLs inside the available space. See Sizing for minimum-width utilities.

URL

https://example.com/a-very-long-path-without-any-natural-wrap-opportunities-that-stays-inside-its-container

HTML
<div class="d-flex align-items-start gap-2">
	<span class="badge flex-shrink-0">URL</span>
	<p class="min-w-0 overflow-wrap-anywhere mb-0">
		https://example.com/a-very-long-path-without-any-natural-wrap-opportunities
	</p>
</div>