Font Smoothing

Utilities for controlling the font smoothing of an element.

Class reference

ClassProperties
.antialiased-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;
.subpixel-antialiased-webkit-font-smoothing: auto;-moz-osx-font-smoothing: auto;

Subpixel Antialiasing

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

Font Smoothing - 图1

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

Grayscale Antialiasing

Use the .antialiased utility to render text using grayscale antialiasing.

Font Smoothing - 图2

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

Responsive

To control the font smoothing of an element at a specific breakpoint, add a {screen}: prefix to any existing font smoothing utility. For example, use md:antialiased to apply the antialiased utility at only medium screen sizes and above.

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

  1. <p class="antialiased sm:subpixel-antialiased md:antialiased lg:subpixel-antialiased xl:antialiased ...">
  2. The quick brown fox jumped over the lazy dog.
  3. </p>

Font Smoothing - 图3

Customizing

Responsive and pseudo-class variants

By default, only responsive variants are generated for font smoothing utilities.

You can control which variants are generated for the font smoothing utilities by modifying the fontSmoothing property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. // ...
  5. - fontSmoothing: ['responsive'],
  6. + fontSmoothing: ['responsive', 'hover', 'focus'],
  7. }
  8. }

Disabling

If you don’t plan to use the font smoothing utilities in your project, you can disable them entirely by setting the fontSmoothing property to false in the corePlugins section of your config file:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + fontSmoothing: false,
  6. }
  7. }