Font Style

Utilities for controlling the style of text.

Class reference

Class
Properties
.italicfont-style: italic;
.not-italicfont-style: normal;

No Italics

Use the .not-italic utility to display text normally. This is typically used to reset italic text at different breakpoints.

Font Style - 图1

  1. <p class="not-italic ...">The quick brown fox ...</p>

Italics

Use the .italic utility to make text italic.

Font Style - 图2

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

Responsive

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

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

Font Style - 图3

all

Font Style - 图4

sm

Font Style - 图5

md

Font Style - 图6

lg

Font Style - 图7

xl

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

The quick brown fox jumped over the lazy dog.

Customizing

Responsive and pseudo-class variants

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

You can control which variants are generated for the font style utilities by modifying the fontStyle 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. - fontStyle: ['responsive'],
  6. + fontStyle: ['responsive', 'hover', 'focus'],
  7. }
  8. }

Disabling

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

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

← Font Smoothing   Font Weight →