Discover how a tiny class name can save you hours of styling work!
Why Text color utilities in Tailwind? - Purpose & Use Cases
Start learning this pattern below
Jump into concepts and practice - no test required
Imagine you are designing a website and want to change the color of many different text elements by writing CSS rules for each one manually.
If you write separate CSS classes for every text color, it takes a lot of time and effort. Also, if you want to change a color later, you must find and update every rule, which is slow and error-prone.
Text color utilities let you quickly apply colors using simple class names. You don't write custom CSS for each color. Instead, you add a class like text-red-500 to change text color instantly.
p { color: #ef4444; } /* red text */
h1 { color: #3b82f6; } /* blue text */<p class="text-red-500">Red text</p> <h1 class="text-blue-500">Blue text</h1>
You can style text colors quickly and consistently across your whole site with just a few utility classes.
When building a blog, you can easily highlight warnings in red and links in blue by adding text-red-600 or text-blue-600 classes without writing extra CSS.
Manual CSS for text colors is slow and hard to maintain.
Text color utilities let you apply colors with simple class names.
This makes styling faster, consistent, and easier to update.
Practice
text-red-500 do to the text?Solution
Step 1: Understand Tailwind text color syntax
The classtext-red-500uses the formattext-{color}-{shade}to set text color.Step 2: Interpret the color and shade
Here,redis the color and500is a medium shade, so it changes text color to medium red.Final Answer:
Changes the text color to a medium shade of red -> Option AQuick Check:
text-red-500 sets medium red text color [OK]
- Confusing text color with background color
- Thinking it changes font weight
- Assuming it adds underline
Solution
Step 1: Recall Tailwind shade numbering
Lower numbers like 100 mean lighter shades, higher numbers like 900 mean darker shades.Step 2: Identify correct syntax for light blue text
text-blue-100is the correct format for light blue text color.Final Answer:
text-blue-100 -> Option CQuick Check:
Light shade uses 100 number [OK]
- Using invalid class names like text-light-blue
- Confusing shade numbers (900 is dark)
- Mixing background and text color classes
<p class="text-green-700">Hello</p>
Solution
Step 1: Analyze the class name
The classtext-green-700sets the text color to green with shade 700, which is a darker shade.Step 2: Match shade to color intensity
Shade 700 is darker than 500 or 400, so the text will appear dark green.Final Answer:
A dark green color -> Option AQuick Check:
Shade 700 means dark color [OK]
- Assuming 700 is light shade
- Mixing green with blue or red
- Ignoring the shade number
<span class="text-purple-">Sample</span>
Solution
Step 1: Check the class syntax
The classtext-purple-ends with a dash but no shade number, which is invalid.Step 2: Confirm correct usage
Tailwind requires a shade number like 100, 500, 700 after the color name for text color classes.Final Answer:
Missing shade number after color name -> Option BQuick Check:
Shade number is required after color [OK]
- Leaving out the shade number
- Confusing text and background classes
- Thinking any element can't have text color
Solution
Step 1: Understand contrast needs on dark backgrounds
Light text colors are easier to read on dark backgrounds, so a light gray or white is best.Step 2: Evaluate the options
text-gray-100is a very light gray, suitable for dark backgrounds.text-gray-900andtext-blackare dark colors, hard to read on dark backgrounds.text-white-500is invalid because white doesn't have shades.Final Answer:
text-gray-100 -> Option DQuick Check:
Light colors for dark backgrounds [OK]
- Using dark text on dark backgrounds
- Assuming white has shade numbers
- Confusing background and text colors
