Utilities for controlling the opacity of an element's text color.
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>
Note that because these utilities are implemented using CSS custom properties, a .text-{color}
utility must be present on the same element for them to work.
Don't try to use text opacity utilities on an inherited text color
<div class="text-black">
<div class="text-opacity-50">...</div>
</div>
Do make sure to add a text color utility to the same element explicitly
<div class="text-black">
<div class="text-black text-opacity-50">...</div>
</div>
To control an element's text color opacity at a specific breakpoint, add a {screen}:
prefix to any existing text color opacity utility. For example, use md:text-opacity-50
to apply the text-opacity-50
utility at only medium screen sizes and above.
<div class="text-blue-500 text-opacity-75 md:text-opacity-50">
<!-- ... -->
</div>
For more information about Tailwind's responsive design features, check out the Responsive Design documentation.
To customize the opacity values for all opacity-related utilities at once, use the opacity
section of your tailwind.config.js
theme configuration:
// tailwind.config.js
module.exports = {
theme: {
extend: {
opacity: {
+ '10': '0.1',
+ '20': '0.2',
+ '95': '0.95',
}
}
}
}
If you want to customize only the text opacity utilities, use the textOpacity
section:
// tailwind.config.js
module.exports = {
theme: {
extend: {
textOpacity: {
+ '10': '0.1',
+ '20': '0.2',
+ '95': '0.95',
}
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
By default, only responsive, dark mode (if enabled), group-hover, focus-within, hover and focus variants are generated for text opacity utilities.
You can control which variants are generated for the text opacity utilities by modifying the textOpacity
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate active variants:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ textOpacity: ['active'],
}
}
}
If you don't plan to use the text opacity utilities in your project, you can disable them entirely by setting the textOpacity
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ textOpacity: false,
}
}