Quick reference

Class
Properties
opacity-0opacity: 0;
opacity-5opacity: 0.05;
opacity-10opacity: 0.1;
opacity-15opacity: 0.15;
opacity-20opacity: 0.2;
opacity-25opacity: 0.25;
opacity-30opacity: 0.3;
opacity-35opacity: 0.35;
opacity-40opacity: 0.4;
opacity-45opacity: 0.45;
opacity-50opacity: 0.5;
opacity-55opacity: 0.55;
opacity-60opacity: 0.6;
opacity-65opacity: 0.65;
opacity-70opacity: 0.7;
opacity-75opacity: 0.75;
opacity-80opacity: 0.8;
opacity-85opacity: 0.85;
opacity-90opacity: 0.9;
opacity-95opacity: 0.95;
opacity-100opacity: 1;

Basic usage

Changing an element’s opacity

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>

Applying conditionally

Hover, focus, and other states

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.

Breakpoints and media queries

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.


Using custom values

Customizing your theme

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.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      opacity: {
        '67': '.67',
      }
    }
  }
}

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

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.