Tailwind CSS Opacity
The opacity utility class in Tailwind CSS allows you to control the transparency of an element.
Tailwind Opacity
The opacity utility class in Tailwind CSS allows you to control the transparency of an element. With Tailwind's opacity class, you can easily adjust the opacity level of an element to create various visual effects.
Applying Opacity
To apply a specific opacity level to an element, you can use the opacity-{value}
utility class, where {value}
represents the desired opacity level. Here are some common values you can use:
- opacity-0: Makes the element completely transparent.
- opacity-25: Sets the element's opacity to 25%.
- opacity-50: Sets the element's opacity to 50%.
- opacity-75: Sets the element's opacity to 75%.
- opacity-100: Makes the element completely opaque (default).
<div class="grid grid-cols-3"> <div class="bg-red-500 opacity-100"> A </div> <div class="bg-red-500 opacity-50"> B </div> <div class=" bg-red-500 opacity-30"> C </div></div>
Preview
Transitioning Opacity
Tailwind CSS also provides utility classes for transitioning the opacity of an element. You can use the transition-opacity
class to add a smooth transition effect when changing the opacity. Here's an example:
<div class="opacity-0 transition-opacity duration-500"> A</div>
Preview
Responsive Opacity
Tailwind CSS allows you to apply opacity classes responsively at different breakpoints. To use responsive opacity classes, you can append the breakpoint prefix to the utility class. For example, md:opacity-50 sets the opacity to 50% starting from the medium breakpoint and above.
<div class="opacity-25 md:opacity-50"> <!-- Content here --></div>
In the above example, the opacity of the <div>
element is set to 25% by default (opacity-25), but starting from the medium breakpoint and above, it changes to 50% (md:opacity-50).
Tailwind CSS OPacity Class Table
Class | Properties |
---|---|
opacity-0 | opacity: 0; |
opacity-5 | opacity: 0.05; |
opacity-10 | opacity: 0.1; |
opacity-20 | opacity: 0.2; |
opacity-25 | opacity: 0.25; |
opacity-30 | opacity: 0.3; |
opacity-40 | opacity: 0.4; |
opacity-50 | opacity: 0.5; |
opacity-60 | opacity: 0.6; |
opacity-70 | opacity: 0.7; |
opacity-75 | opacity: 0.75; |
opacity-80 | opacity: 0.8; |
opacity-90 | opacity: 0.9; |
opacity-95 | opacity: 0.95; |
opacity-100 | opacity: 1; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs