When to Use
- Animate component entrance and exit
- Create smooth expand/collapse animations
- Handle modal and dialog transitions
- Animate list item additions and removals
- Build custom animated components with mount/unmount states
Basic Usage
Component API
boolean
required
Whether the component should be present (mounted) or not
React.ReactElement | ((context: RenderPropContext) => React.ReactElement)
Element to animate. Can be a render function receiving animation state
'animation' | 'transition'
default:"animation"
Type of CSS animation to use. ‘animation’ for @keyframes, ‘transition’ for CSS transitions
() => void
Callback fired when the exit animation completes and element unmounts
boolean
default:"false"
Always render the element, even when not present. Useful for testing or specific animation needs
string
Additional CSS classes to apply to the wrapper
Render Prop Context
boolean
Current presence state (mounted or not)
boolean
True if present or transition variant is complete
boolean
Whether the transition should start (for transition variant)
Data Attributes
The component adds these data attributes for styling:data-state: Current state ("mounted"|"unmountSuspended"|"unmounted")data-present: Whether currently present ("true"|undefined)data-present-or-transition-complete: Transition completion statedata-transition: Transition state ("active"|"inactive") - only forvariant="transition"
Examples
Fade Animation
Slide and Fade
Using Transition Variant
Render Prop Pattern
Modal with Backdrop
Comparison to Native Patterns
Traditional Conditional Rendering
This provides no animation - the element immediately appears/disappears.
With Presence
The element smoothly animates in and out based on your CSS.
Common Use Cases
Collapsible Section
Notification Toast
Animated List Items
Based on Radix UI Presence with enhanced variant support for both CSS animations and transitions.