Utilities for controlling the visibility of an element.
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 space-x-4">
<div>1</div>
<div class="invisible ...">2</div>
<div>3</div>
</div>
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 space-x-4">
<div>1</div>
<div class="visible ...">2</div>
<div>3</div>
</div>
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.
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'],
}
}
}
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,
}
}