@starting-style and the light-dark() function.
Animation Classes
Pop-in Animation
The.animate-pop-in class creates a swinging entrance effect for modals and dialogs:
- Duration:
150ms - Easing:
cubic-bezier(0.4, 0, 0.2, 1)(ease-in-out) - Entry: Rotates from
-15degwith perspective, translates from-80pxon Z-axis - Exit: Reverses the animation when
[data-state="closing"]is applied - Includes backdrop fade
Slide-in Animation
The.animate-slide-in class creates a smooth slide effect for toasts and notifications:
- Duration:
150ms - Easing:
cubic-bezier(0.16, 1, 0.3, 1)(spring easing) - Entry: Slides from 100% right (off-screen)
- Exit: Slides back to 100% right when
[data-state="closing"]is applied
Dialog Backdrop Animation
Dialog backdrops automatically fade in and out:How Animations Work
Oat’s animations use modern CSS features:@starting-style
The@starting-style at-rule defines where animations begin:
@starting-style state to the default state.
Data State Attribute
Exit animations use thedata-state="closing" attribute:
data-state="closing" to trigger the exit animation.
Discrete Animations
For properties likedisplay and overlay, use allow-discrete:
display property changes.
Customizing Animations
Adjust Duration
Override animation duration globally or per component:Adjust Easing
Change the easing curve for different animation feels:Custom Entry Animation
Modify where elements animate from:Disable Animations
Respect user preferences withprefers-reduced-motion:
Creating Custom Animations
Example: Fade Animation
Example: Scale Animation
Example: Slide from Bottom
Performance Tips
- Use transform and opacity: These properties are GPU-accelerated and don’t trigger layout recalculations.
- Use will-change sparingly: Only for elements that will definitely animate.
- Keep durations short: 150-300ms feels snappy without being jarring.
-
Respect reduced motion: Always include
prefers-reduced-motionsupport.
Animation Timing Reference
Easing Functions
Duration Guidelines
- 50-100ms: Instant feedback (hover, focus)
- 150-200ms: Quick transitions (most UI changes)
- 250-300ms: Moderate transitions (page changes)
- 400-500ms: Slow, deliberate (large movements)
Using Transition Variables
Oat provides transition variables for consistency:JavaScript Integration
Manually trigger animations with JavaScript:Browser Support
Oat’s animations use modern CSS features:@starting-style: Chrome 117+, Safari 17.5+light-dark(): Chrome 123+, Safari 17.5+allow-discrete: Chrome 117+, Safari 17.4+