Effects
Utilities for controlling the opacity of an element.
Use the opacity-*
utilities to control the opacity of an element.
opacity-100
opacity-75
opacity-50
opacity-25
<button class="bg-indigo-500 opacity-100 ..."></button>
<button class="bg-indigo-500 opacity-75 ..."></button>
<button class="bg-indigo-500 opacity-50 ..."></button>
<button class="bg-indigo-500 opacity-25 ..."></button>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:opacity-100
to only apply the opacity-100
utility on hover.
<div class="opacity-50 hover:opacity-100">
<!-- ... -->
</div>
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:opacity-100
to apply the opacity-100
utility at only medium screen sizes and above.
<div class="opacity-50 md:opacity-100">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind provides several opacity utilities for general purpose use. You can customize these values by editing theme.opacity
or theme.extend.opacity
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
opacity: {
'67': '.67',
}
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off opacity
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.
<div class="opacity-[.67]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.