Transition
Animate presence of component with pre-made animations
Source
LLM docs
Docs
PackageIcon
Usage
The Transition component is designed to animate the presence of elements with fixed or absolute positioning, such as dropdowns, modals, or tooltips. Other Mantine components (like Modal and Tooltip) use Transition internally for their animations.
Note that the Transition component is not intended to be a comprehensive solution for all animations. It is a simple utility for animating the presence of elements with fixed or absolute positioning. If you need to implement more complex animations, consider using Motion, React Spring, or other dedicated animation libraries.
Example usage of the Transition component:
Premade transitions
Mantine includes several premade transitions:
To use one of them, set the transition property to one of these values:
Custom transitions
You can create your own transition. transition is an object with 4 properties:
in– styles for mounted stateout– styles for unmounted statecommon(optional) – styles for both mounted and unmounted statestransitionProperty– properties which participate in the transition
Enter and exit delay
Use the enterDelay and exitDelay props to delay the transition start. Values are in milliseconds:
Reduced motion
Transition respects the prefers-reduced-motion media query and your theme's
respectReducedMotion setting. When reduced motion is preferred, all
transitions complete instantly:
This improves accessibility for users with vestibular disorders who may experience motion sickness from animations.
Lifecycle callbacks
Use lifecycle callbacks to perform actions at different stages of the transition:
onEnter- Called when enter transition startsonEntered- Called when enter transition completesonExit- Called when exit transition startsonExited- Called when exit transition completes
Keep mounted
By default, the element is unmounted from the DOM when the transition is
complete. Use keepMounted to keep the element mounted with display: none:
This is useful when you want to:
- Preserve element state during hide/show
- Avoid remounting overhead
- Maintain focus/scroll position