Font Style

Utilities for controlling the style of text.

Default class reference

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

Italics

Use the italic utility to make text italic.

Font Style - 图1

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

Undo Italics

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

Font Style - 图2

  1. <p class="not-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:not-italic to apply the not-italic utility at only medium screen sizes and above.

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

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

Customizing

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. extend: {
  5. // ...
  6. + fontStyle: ['hover', 'focus'],
  7. }
  8. }
  9. }

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→

Edit this page on GitHub