opacity

Utilities for controlling the opacity of an element.

2025-04-12

Written by: tdtc

ClassStyles
opacity-<number>opacity: <number>%;
opacity-(<custom-property>)opacity: var(<custom-property>);
opacity-[<value>]opacity: <value>;

Basic example

Use opacity- utilities like opacity-25 and opacity-100 to set the opacity of an element:

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

Applying conditionally

Prefix an opacity utility with a variant like disabled:* to only apply the utility in that state:

<input class="opacity-100 disabled:opacity-75 ..." type="text" />

Learn more about using variants in the variants documentation.

Using a custom value

Use the opacity-[] syntax to set the opacity based on a completely custom value:

<button class="opacity-[.67] ...">
  <!-- ... -->
</button>

Ref