Typography
Utilities for controlling the text color of an element.
Use the text-*
utilities to control the text color of an element.
The quick brown fox jumps over the lazy dog.
<p class="text-blue-600">The quick brown fox...</p>
<p class="text-sky-400">The quick brown fox...</p>
Use the color opacity modifier to control the opacity of an element’s text color.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
<p class="text-blue-600/100">The quick brown fox...</p> <p class="text-blue-600/75">The quick brown fox...</p> <p class="text-blue-600/50">The quick brown fox...</p> <p class="text-blue-600/25">The quick brown fox...</p> <p class="text-blue-600/0">The quick brown fox...</p>
<p class="text-sky-400/100">The quick brown fox...</p> <p class="text-sky-400/75">The quick brown fox...</p> <p class="text-sky-400/50">The quick brown fox...</p> <p class="text-sky-400/25">The quick brown fox...</p> <p class="text-sky-400/0">The quick brown fox...</p>
You can use any value defined in your opacity scale, or use arbitrary values if you need to deviate from your design tokens.
<p class="text-blue-600/[.06]">The quick brown fox...</p>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:text-blue-600
to only apply the text-blue-600
utility on hover.
Try hovering over the text to see the expected behaviour
The quick brown fox jumps over the lazy dog.
<p class="text-slate-500 hover:text-blue-600">The quick brown fox...</p>
<p class="text-slate-400 hover:text-sky-400">The quick brown fox...</p>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:text-green-600
to apply the text-green-600
utility at only medium screen sizes and above.
<p class="text-blue-600 md:text-green-600">
<!-- ... -->
</p>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind makes the entire default color palette available as text colors. You can customize your color palette by editing theme.colors
or theme.extend.colors
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
colors: {
'regal-blue': '#243c5a',
},
}
}
}
Alternatively, you can customize just your text colors by editing theme.textColor
or theme.extend.textColor
in your tailwind.config.js
file.
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off color
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<p class="text-[#50d71e]">
<!-- ... -->
</p>
Learn more about arbitrary value support in the arbitrary values documentation.