Visibility

Utilities for controlling the visibility of an element.

Class reference

Class
Properties
.visiblevisibility: visible;
.invisiblevisibility: hidden;

Visible

Use .visible to make an element visible. This is mostly useful for undoing the .invisible utility at different screen sizes.

<div class="flex justify-center">
  <div class="bg-gray-400"></div>
  <div class="bg-gray-600 visible"></div>
  <div class="bg-gray-400"></div>
</div>

Invisible

Use .invisible to hide an element, but still maintain its place in the DOM, affecting the layout of other elements (compare with .hidden from the display documentation).

<div class="flex justify-center">
  <div class="bg-gray-400"></div>
  <div class="bg-gray-600 invisible"></div>
  <div class="bg-gray-400"></div>
</div>

Responsive

To apply a visibility utility only at a specific breakpoint, add a {screen}: prefix to the existing class name. For example, adding the class md:invisible to an element would apply the invisible utility at medium screen sizes and above.

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.

<div class="flex justify-center">
  <div class="bg-gray-400"></div>
  <div class="bg-gray-600 visible sm:invisible md:visible lg:invisible xl:visible"></div>
  <div class="bg-gray-400"></div>
</div>

Customizing

Responsive and pseudo-class variants

By default, only responsive variants are generated for visibility utilities.

You can control which variants are generated for the visibility utilities by modifying the visibility property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  // tailwind.config.js
  module.exports = {
    variants: {
      // ...
-     visibility: ['responsive'],
+     visibility: ['responsive', 'hover', 'focus'],
    }
  }

Disabling

If you don't plan to use the visibility utilities in your project, you can disable them entirely by setting the visibility property to false in the corePlugins section of your config file:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     visibility: false,
    }
  }

Tailwind UI is now in early access!