Last updated: 20 May 2024

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).
html
<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

A
B
C

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:

html
<div class="opacity-0 transition-opacity duration-500">
A
</div>

Preview

A

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.

html
<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

ClassProperties
opacity-0 opacity: 0;
opacity-5opacity: 0.05;
opacity-10opacity: 0.1;
opacity-20opacity: 0.2;
opacity-25opacity: 0.25;
opacity-30opacity: 0.3;
opacity-40opacity: 0.4;
opacity-50opacity: 0.5;
opacity-60opacity: 0.6;
opacity-70opacity: 0.7;
opacity-75opacity: 0.75;
opacity-80opacity: 0.8;
opacity-90opacity: 0.9;
opacity-95opacity: 0.95;
opacity-100opacity: 1;

Windframe Tailwind blocks

Pricing

Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs

Start building stunning tailwind UIs! 

Build from scratch or select prebuilt tailwind templates