Utilities for controlling the fill mode of CSS animations.
Class | Properties |
---|---|
fill-mode-none |
animation-fill-mode: none; |
fill-mode-forwards |
animation-fill-mode: forwards; |
fill-mode-backwards |
animation-fill-mode: backwards; |
fill-mode-both |
animation-fill-mode: both; |
Use the fill-mode-{keyword}
utilities to control an element’s animation-fill-mode
.
<button class="animate-bounce fill-mode-none ...">Button A</button>
<button class="animate-bounce fill-mode-forwards ...">Button B</button>
<button class="animate-bounce fill-mode-backwards ...">Button C</button>
<button class="animate-bounce fill-mode-both ...">Button C</button>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:fill-mode-forwards
to only apply the fill-mode-forwards
utility on hover.
<div
class="animate-bounce duration-300 fill-mode-backwards hover:fill-mode-forwards"
>
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:fill-mode-forwards
to apply the fill-mode-forwards
utility at only medium screen sizes and above.
<div
class="animate-bounce duration-300 fill-mode-backwards md:fill-mode-forwards"
>
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind provides animation-direction
utilities for all of the built-in browser keyword options. You can customize these values by editing theme.animationDirection
or theme.extend.animationDirection
in your tailwind.config.js
file.
// @filename tailwind.config.js
module.exports = {
theme: {
extend: {
animationDirection: {
"forwards-backwards": "forwards, backwards",
},
},
},
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off animation-fill-mode
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="fill-mode-[forwards,backwards]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.