Text Color

Utilities for controlling the text color of an element.

Class reference

Class
Preview 
.text-transparentAa
.text-currentAa
.text-blackAa
.text-whiteAa
.text-gray-100Aa
.text-gray-200Aa
.text-gray-300Aa
.text-gray-400Aa
.text-gray-500Aa
.text-gray-600Aa
.text-gray-700Aa
.text-gray-800Aa
.text-gray-900Aa
.text-red-100Aa
.text-red-200Aa
.text-red-300Aa
.text-red-400Aa
.text-red-500Aa
.text-red-600Aa
.text-red-700Aa
.text-red-800Aa
.text-red-900Aa
.text-orange-100Aa
.text-orange-200Aa
.text-orange-300Aa
.text-orange-400Aa
.text-orange-500Aa
.text-orange-600Aa
.text-orange-700Aa
.text-orange-800Aa
.text-orange-900Aa
.text-yellow-100Aa
.text-yellow-200Aa
.text-yellow-300Aa
.text-yellow-400Aa
.text-yellow-500Aa
.text-yellow-600Aa
.text-yellow-700Aa
.text-yellow-800Aa
.text-yellow-900Aa
.text-green-100Aa
.text-green-200Aa
.text-green-300Aa
.text-green-400Aa
.text-green-500Aa
.text-green-600Aa
.text-green-700Aa
.text-green-800Aa
.text-green-900Aa
.text-teal-100Aa
.text-teal-200Aa
.text-teal-300Aa
.text-teal-400Aa
.text-teal-500Aa
.text-teal-600Aa
.text-teal-700Aa
.text-teal-800Aa
.text-teal-900Aa
.text-blue-100Aa
.text-blue-200Aa
.text-blue-300Aa
.text-blue-400Aa
.text-blue-500Aa
.text-blue-600Aa
.text-blue-700Aa
.text-blue-800Aa
.text-blue-900Aa
.text-indigo-100Aa
.text-indigo-200Aa
.text-indigo-300Aa
.text-indigo-400Aa
.text-indigo-500Aa
.text-indigo-600Aa
.text-indigo-700Aa
.text-indigo-800Aa
.text-indigo-900Aa
.text-purple-100Aa
.text-purple-200Aa
.text-purple-300Aa
.text-purple-400Aa
.text-purple-500Aa
.text-purple-600Aa
.text-purple-700Aa
.text-purple-800Aa
.text-purple-900Aa
.text-pink-100Aa
.text-pink-200Aa
.text-pink-300Aa
.text-pink-400Aa
.text-pink-500Aa
.text-pink-600Aa
.text-pink-700Aa
.text-pink-800Aa
.text-pink-900Aa

Usage

Control the text color of an element using the .text-{color} utilities.

The quick brown fox jumped over the lazy dog.
<input class="text-purple-600 ...">

Changing opacityv1.4.0+

Control the opacity of an element's text color using the .text-opacity-{amount} utilities.

The quick brown fox jumped over the lazy dog.

The quick brown fox jumped over the lazy dog.

The quick brown fox jumped over the lazy dog.

The quick brown fox jumped over the lazy dog.

The quick brown fox jumped over the lazy dog.

<p class="text-purple-700 text-opacity-100">The quick brown fox ...</p>
<p class="text-purple-700 text-opacity-75">The quick brown fox ...</p>
<p class="text-purple-700 text-opacity-50">The quick brown fox ...</p>
<p class="text-purple-700 text-opacity-25">The quick brown fox ...</p>
<p class="text-purple-700 text-opacity-0">The quick brown fox ...</p>

Learn more in the text opacity documentation.

Responsive

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

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

<div class="text-blue-600 sm:text-green-600 md:text-indigo-600 lg:text-red-600 xl:text-gray-900 ...">
  The quick brown fox...
</div>
The quick brown fox jumped over the lazy dog.

Hover

To control the text color of an element on hover, add the hover: prefix to any existing text color utility. For example, use hover:text-blue-600 to apply the text-blue-600 utility on hover.

<button class="text-blue-600 hover:text-red-600 ...">
  Button
</button>

Hover utilities can also be combined with responsive utilities by adding the responsive {screen}: prefix before the hover: prefix.

<button class="... md:text-blue-500 md:hover:text-blue-600 ...">Button</button>

Focus

To control the text color of an element on focus, add the focus: prefix to any existing text color utility. For example, use focus:text-blue-600 to apply the text-blue-600 utility on focus.

<input class="text-gray-900 focus:text-red-600 ...">

Focus utilities can also be combined with responsive utilities by adding the responsive {screen}: prefix before the focus: prefix.

<input class="... md:text-gray-900 md:focus:text-red-600 ...">

Customizing

Text Colors

By default Tailwind makes the entire default color palette available as text colors.

You can customize your color palette by editing theme.colors in your tailwind.config.js file, or customize just your text colors in the theme.textColor section.

  // tailwind.config.js
  module.exports = {
    theme: {
-     textColor: theme => theme('colors'),
+     textColor: {
+       'primary': '#3490dc',
+       'secondary': '#ffed4a',
+       'danger': '#e3342f',
+     }
    }
  }

Responsive and pseudo-class variants

By default, only responsive, hover and focus variants are generated for text color utilities.

You can control which variants are generated for the text color utilities by modifying the textColor property in the variants section of your tailwind.config.js file.

For example, this config will also generate active and group-hover variants:

  // tailwind.config.js
  module.exports = {
    variants: {
      // ...
-     textColor: ['responsive', 'hover', 'focus'],
+     textColor: ['responsive', 'hover', 'focus', 'active', 'group-hover'],
    }
  }

Disabling

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

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     textColor: false,
    }
  }

Tailwind UI is now in early access!