Class reference

Color - 图1

Usage

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

Color - 图2

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 to apply the text-green utility at only medium screen sizes and above.

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

Color - 图3

all

Color - 图4

sm

Color - 图5

md

Color - 图6

lg

Color - 图7

xl

Color - 图8

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 to apply the text-blue utility on hover.

Color - 图9

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

  1. <button class="... md:text-blue md:hover:text-blue-dark ...">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 to apply the text-blue utility on focus.

Color - 图10

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

  1. <input class="... md:text-black md:focus:text-red ...">

Customizing

Text Colors

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

You can customize your color palette by editing the colors variable in your Tailwind config file, or customize just your text colors using the textColors section of your Tailwind config.

Color - 图11

Responsive and State 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 textColors property in the modules section of your Tailwind config file.

For example, this config will also generate variants:

Color - 图12

Disabling

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

Color - 图13