Check out our free templates made with AI and polished to perfection in Windframe

Get now
Last updated: 14 July 2025

Tailwind CSS Text Color

The text-color utility class in Tailwind CSS allows you to easily set the color of text within elements.


Tailwind Text Color

Tailwind's text-{color} utility allows you to set the text color of any element using a scalable, consistent system. With Tailwind's text color classes, you can quickly apply different colors to your text without writing custom CSS or you can also write your own custom color and apply it.

How to apply Tailwind Text Color

To apply a Tailwind text color to an element, you can use the text-{color} utility class, where {color} represents the desired color. Tailwind CSS provides a wide range of color options that you can use out of the box.

html
<div class="text-red-500">This text has a red color.</div>

Preview

This text has the text color of red

Color Variants

Tailwind CSS includes color variants that you can use to modify the brightness or opacity of a color. These variants are specified using a number from 100 to 900. For example, you can use text-red-100 for a lighter shade of red and text-red-900 for a darker shade of red.

html
<div class="text-green-300">This text has a lighter shade of green color.</div>
<div class="text-green-700">This text has a darker shade of green color.</div>

Preview

This text has a lighter shade of green color.

This text has a darker shade of green color.

In the above example, the text-red-100 class is applied to the first <div> element, setting its text color to a lighter shade of red. The text-red-900 class is applied to the second <div> element, setting its text color to a darker shade of red.

✏️ Arbitrary Value Usage

Need full control? Use arbitrary values for custom or one-off colors.

Hex, RGB, HSL:

html
<p class="text-[#ff5733]">Hex color</p>
<p class="text-[rgb(30,144,255)]">RGB color</p>
<p class="text-[hsl(200,100%,50%)]">HSL color</p>

Preview

Hex color

RGB color

HSL color

Use this for edge cases or dynamic theming scenarios.

Responsive Text Color

Tailwind CSS allows you to apply text colors responsively at different breakpoints. Use responsive prefixes to change text color at different screen sizes. For example, md:text-green-500 applies the green text color starting from the medium breakpoint and above.

html
<p class="text-gray-500 sm:text-gray-700 md:text-gray-900">
Text darkens on larger screens
</p>

Preview

Text darkens on larger screens

Useful for adapting color contrast as layout and backgrounds shift across breakpoints.

🎯 Interaction State Use (hover/focus)

Tailwind makes it easy to change text color on hover, focus, and active states.

Hover example:

html
<a href="#" class="text-gray-600 hover:text-blue-600"> Hover to highlight </a>

Preview

Focus example:

html
<h1 class="text-2xl font-bold text-center mb-5">Fill the form</h1>
<label class="m-1 text-gray-700 font-bold">Email</label>
<input class="text-gray-700 focus:text-black p-2 border-2 border-gray-300 rounded-lg" placeholder="email" />
</div>

Preview

Fill the form

You can also target group-hover, focus-within, or active states for advanced interactivity.

⚙️ Customization in tailwind.config.js

Tailwind CSS also allows you to define your own custom colors in the configuration file. Once defined, you can use your custom colors with the text-{color} utility class.

js
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
brand: {
DEFAULT: "#1a73e8",
dark: "#174ea6",
},
},
},
},
};
html
<h1 class="text-brand">Brand Blue</h1>
<p class="text-brand-dark">Dark brand shade</p>

Preview

Brand Blue

Dark brand shade

This creates a consistent visual language in your app.

🧩 Real UI Component Examples

🔹 Button with Hover Text Color

html
<button
class="px-4 py-2 border rounded text-indigo-600 hover:text-white hover:bg-indigo-600 transition"
>
Hover Me
</button>

Preview

🔹 Alert Component

html
<div class="bg-red-100 border border-red-300 p-4 text-red-700">
⚠️ Error: Something went wrong.
</div>

Preview

⚠️ Error: Something went wrong.

✅ Best Practices for Devs & Designers

  • Use contrast-aware text colors (e.g., text-white on dark backgrounds, text-gray-900 on light).

  • Pair text-* with bg-* mindfully for accessible color combinations.

  • Use semantic naming when customizing (text-error, text-success, text-muted) via tailwind.config.js.

  • Avoid using too many shades of the same color — stick to a 3–5 tone scale (light, base, dark, hover, disabled).

♿ Accessibility Notes

  • Avoid low-contrast combinations like text-gray-400 on bg-white for body text.

  • Use browser tools or plugins (e.g., axe DevTools) to test contrast levels.

Tailwind CSS Text Color Class Table

ClassProperties
text-transparentcolor: transparent;
text-currentcolor: currentColor;
text-black--tw-text-opacity: 1;color: rgba(0, 0, 0, var(--tw-text-opacity));
text-white--tw-text-opacity: 1;color: rgba(255, 255, 255, var(--tw-text-opacity));
text-gray-50--tw-text-opacity: 1;color: rgba(249, 250, 251, var(--tw-text-opacity));
text-gray-100--tw-text-opacity: 1;color: rgba(243, 244, 246, var(--tw-text-opacity));
text-gray-200--tw-text-opacity: 1;color: rgba(229, 231, 235, var(--tw-text-opacity));
text-gray-300--tw-text-opacity: 1;color: rgba(209, 213, 219, var(--tw-text-opacity));
text-gray-400--tw-text-opacity: 1;color: rgba(156, 163, 175, var(--tw-text-opacity));
text-gray-500--tw-text-opacity: 1;color: rgba(107, 114, 128, var(--tw-text-opacity));
text-gray-600--tw-text-opacity: 1;color: rgba(75, 85, 99, var(--tw-text-opacity));
text-gray-700--tw-text-opacity: 1;color: rgba(55, 65, 81, var(--tw-text-opacity));
text-gray-800--tw-text-opacity: 1;color: rgba(31, 41, 55, var(--tw-text-opacity));
text-gray-900--tw-text-opacity: 1;color: rgba(17, 24, 39, var(--tw-text-opacity));
text-red-50--tw-text-opacity: 1;color: rgba(254, 242, 242, var(--tw-text-opacity));
text-red-100--tw-text-opacity: 1;color: rgba(254, 226, 226, var(--tw-text-opacity));
text-red-200--tw-text-opacity: 1;color: rgba(254, 202, 202, var(--tw-text-opacity));
text-red-300--tw-text-opacity: 1;color: rgba(252, 165, 165, var(--tw-text-opacity));
text-red-400--tw-text-opacity: 1;color: rgba(248, 113, 113, var(--tw-text-opacity));
text-red-500--tw-text-opacity: 1;color: rgba(239, 68, 68, var(--tw-text-opacity));
text-red-600--tw-text-opacity: 1;color: rgba(220, 38, 38, var(--tw-text-opacity));
text-red-700--tw-text-opacity: 1;color: rgba(185, 28, 28, var(--tw-text-opacity));
text-red-800--tw-text-opacity: 1;color: rgba(153, 27, 27, var(--tw-text-opacity));
text-red-900--tw-text-opacity: 1;color: rgba(127, 29, 29, var(--tw-text-opacity));
text-yellow-50--tw-text-opacity: 1;color: rgba(255, 251, 235, var(--tw-text-opacity));
text-yellow-100--tw-text-opacity: 1;color: rgba(254, 243, 199, var(--tw-text-opacity));
text-yellow-200--tw-text-opacity: 1;color: rgba(253, 230, 138, var(--tw-text-opacity));
text-yellow-300--tw-text-opacity: 1;color: rgba(252, 211, 77, var(--tw-text-opacity));
text-yellow-400--tw-text-opacity: 1;color: rgba(251, 191, 36, var(--tw-text-opacity));
text-yellow-500--tw-text-opacity: 1;color: rgba(245, 158, 11, var(--tw-text-opacity));
text-yellow-600--tw-text-opacity: 1;color: rgba(217, 119, 6, var(--tw-text-opacity));
text-yellow-700--tw-text-opacity: 1;color: rgba(180, 83, 9, var(--tw-text-opacity));
text-yellow-800--tw-text-opacity: 1;color: rgba(146, 64, 14, var(--tw-text-opacity));
text-yellow-900--tw-text-opacity: 1;color: rgba(120, 53, 15, var(--tw-text-opacity));
text-green-50--tw-text-opacity: 1;color: rgba(236, 253, 245, var(--tw-text-opacity));
text-green-100--tw-text-opacity: 1;color: rgba(209, 250, 229, var(--tw-text-opacity));
text-green-200--tw-text-opacity: 1;color: rgba(167, 243, 208, var(--tw-text-opacity));
text-green-300--tw-text-opacity: 1;color: rgba(110, 231, 183, var(--tw-text-opacity));
text-green-400--tw-text-opacity: 1;color: rgba(52, 211, 153, var(--tw-text-opacity));
text-green-500--tw-text-opacity: 1;color: rgba(16, 185, 129, var(--tw-text-opacity));
text-green-600--tw-text-opacity: 1;color: rgba(5, 150, 105, var(--tw-text-opacity));
text-green-700--tw-text-opacity: 1;color: rgba(4, 120, 87, var(--tw-text-opacity));
text-green-800--tw-text-opacity: 1;color: rgba(6, 95, 70, var(--tw-text-opacity));
text-green-900--tw-text-opacity: 1;color: rgba(6, 78, 59, var(--tw-text-opacity));
text-blue-50--tw-text-opacity: 1;color: rgba(239, 246, 255, var(--tw-text-opacity));
text-blue-100--tw-text-opacity: 1;color: rgba(219, 234, 254, var(--tw-text-opacity));
text-blue-200--tw-text-opacity: 1;color: rgba(191, 219, 254, var(--tw-text-opacity));
text-blue-300--tw-text-opacity: 1;color: rgba(147, 197, 253, var(--tw-text-opacity));
text-blue-400--tw-text-opacity: 1;color: rgba(96, 165, 250, var(--tw-text-opacity));
text-blue-500--tw-text-opacity: 1;color: rgba(59, 130, 246, var(--tw-text-opacity));
text-blue-600--tw-text-opacity: 1;color: rgba(37, 99, 235, var(--tw-text-opacity));
text-blue-700--tw-text-opacity: 1;color: rgba(29, 78, 216, var(--tw-text-opacity));
text-blue-800--tw-text-opacity: 1;color: rgba(30, 64, 175, var(--tw-text-opacity));
text-blue-900--tw-text-opacity: 1;color: rgba(30, 58, 138, var(--tw-text-opacity));
text-indigo-50--tw-text-opacity: 1;color: rgba(238, 242, 255, var(--tw-text-opacity));
text-indigo-100--tw-text-opacity: 1;color: rgba(224, 231, 255, var(--tw-text-opacity));
text-indigo-200--tw-text-opacity: 1;color: rgba(199, 210, 254, var(--tw-text-opacity));
text-indigo-300--tw-text-opacity: 1;color: rgba(165, 180, 252, var(--tw-text-opacity));
text-indigo-400--tw-text-opacity: 1;color: rgba(129, 140, 248, var(--tw-text-opacity));
text-indigo-500--tw-text-opacity: 1;color: rgba(99, 102, 241, var(--tw-text-opacity));
text-indigo-600--tw-text-opacity: 1;color: rgba(79, 70, 229, var(--tw-text-opacity));
text-indigo-700--tw-text-opacity: 1;color: rgba(67, 56, 202, var(--tw-text-opacity));
text-indigo-800--tw-text-opacity: 1;color: rgba(55, 48, 163, var(--tw-text-opacity));
text-indigo-900--tw-text-opacity: 1;color: rgba(49, 46, 129, var(--tw-text-opacity));
text-purple-50--tw-text-opacity: 1;color: rgba(250, 245, 255, var(--tw-text-opacity));
text-purple-100--tw-text-opacity: 1;color: rgba(243, 232, 255, var(--tw-text-opacity));
text-purple-200--tw-text-opacity: 1;color: rgba(233, 213, 255, var(--tw-text-opacity));
text-purple-300--tw-text-opacity: 1;color: rgba(216, 180, 254, var(--tw-text-opacity));
text-purple-400--tw-text-opacity: 1;color: rgba(192, 132, 252, var(--tw-text-opacity));
text-purple-500--tw-text-opacity: 1;color: rgba(168, 85, 247, var(--tw-text-opacity));
text-purple-600--tw-text-opacity: 1;color: rgba(147, 51, 234, var(--tw-text-opacity));
text-purple-700--tw-text-opacity: 1;color: rgba(126, 34, 206, var(--tw-text-opacity));
text-purple-800--tw-text-opacity: 1;color: rgba(107, 33, 168, var(--tw-text-opacity));
text-purple-900--tw-text-opacity: 1;color: rgba(88, 28, 135, var(--tw-text-opacity));
text-pink-50--tw-text-opacity: 1;color: rgba(253, 242, 248, var(--tw-text-opacity));
text-pink-100--tw-text-opacity: 1;color: rgba(252, 231, 243, var(--tw-text-opacity));
text-pink-200--tw-text-opacity: 1;color: rgba(251, 207, 232, var(--tw-text-opacity));
text-pink-300--tw-text-opacity: 1;color: rgba(249, 168, 212, var(--tw-text-opacity));
text-pink-400--tw-text-opacity: 1;color: rgba(244, 114, 182, var(--tw-text-opacity));
text-pink-500--tw-text-opacity: 1;color: rgba(236, 72, 153, var(--tw-text-opacity));
text-pink-600--tw-text-opacity: 1;color: rgba(219, 39, 119, var(--tw-text-opacity));
text-pink-700--tw-text-opacity: 1;color: rgba(190, 24, 93, var(--tw-text-opacity));
text-pink-800--tw-text-opacity: 1;color: rgba(157, 23, 77, var(--tw-text-opacity));
text-pink-900--tw-text-opacity: 1;color: rgba(131, 24, 67, var(--tw-text-opacity));

🔍 Keep Exploring

Windframe Tailwind blocks

Landing page

Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs

Start building stunning tailwind UIs! 

Build from scratch or select prebuilt tailwind templates