Isolation
Tailwind CSS version
v2.1+
Utilities for controlling whether an element should explicitly create a new stacking context.
Default class reference
Class | Properties |
---|---|
isolate | isolation: isolate; |
isolation-auto | isolation: auto; |
Usage
Use the isolate
and isolation-auto
utilities to control whether an element should explicitly create a new stacking context.
<div class="isolate ...">
<!-- ... -->
</div>
Responsive
To control the isolation property at a specific breakpoint, add a {screen}:
prefix to any existing isolation utility. For example, use md:isolation-auto
to apply the isolation-auto
utility at only medium screen sizes and above.
<div class="isolate md:isolation-auto ...">
<!-- ... -->
</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 isolation utilities.
You can control which variants are generated for the isolation utilities by modifying the isolation
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: {
// ...
+ isolation: ['hover', 'focus'],
}
}
}
Disabling
If you don’t plan to use the isolation utilities in your project, you can disable them entirely by setting the isolation
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ isolation: false,
}
}