Text Transform

Utilities for controlling the transformation of text.

Default class reference

Class
Properties
uppercasetext-transform: uppercase;
lowercasetext-transform: lowercase;
capitalizetext-transform: capitalize;
normal-casetext-transform: none;

Normal Case

Use the normal-case utility to preserve the original casing. This is typically used to reset capitalization at different breakpoints.

Text Transform - 图1

  1. <p class="normal-case ...">The quick brown fox ...</p>

Uppercase

Use the uppercase utility to uppercase text.

Text Transform - 图2

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

Lowercase

Use the lowercase utility to lowercase text.

Text Transform - 图3

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

Capitalize

Use the capitalize utility to capitalize text.

Text Transform - 图4

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

Responsive

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

  1. <p class="capitalize md:uppercase ...">
  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 text transformation utilities.

You can control which variants are generated for the text transformation utilities by modifying the textTransform 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. + textTransform: ['hover', 'focus'],
  7. }
  8. }
  9. }

Disabling

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

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

←Text Decoration Text Overflow→

Edit this page on GitHub