Typography

Font Smoothing

Utilities for controlling the font smoothing of an element.

Quick reference

Class
Properties
antialiased-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
subpixel-antialiased-webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto;

Basic usage

Applying font smoothing

Use the subpixel-antialiased utility to render text using subpixel antialiasing and the antialiased utility to render text using grayscale antialiasing.

Font Smoothing - 图1

  1. <p class="subpixel-antialiased ...">The quick brown fox ...</p>
  2. <p class="antialiased ...">The quick brown fox ...</p>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:subpixel-antialiased to only apply the subpixel-antialiased utility on hover.

  1. <p class="antialiased hover:subpixel-antialiased">
  2. <!-- ... -->
  3. </p>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:subpixel-antialiased to apply the subpixel-antialiased utility at only medium screen sizes and above.

  1. <p class="antialiased md:subpixel-antialiased">
  2. <!-- ... -->
  3. </p>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.