Tailwind CSS on GitHub

Visibility

Utilities for controlling the visibility of an element.

Default class reference

Class
Properties
visiblevisibility: visible;
invisiblevisibility: hidden;

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

1
3
<div class="flex justify-center space-x-4">
  <div>1</div>
  <div class="invisible ...">2</div>
  <div>3</div>
</div>

Visible

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

1
2
3
<div class="flex justify-center space-x-4">
  <div>1</div>
  <div class="visible ...">2</div>
  <div>3</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.

<div class="visible md:invisible ..."></div>

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

Customizing

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: {
      extend: {
        // ...
+       visibility: ['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,
    }
  }