Animations
Built-in keyframe animations, duration and easing CSS variables, and parametric transform utilities.
The UnoCSS preset and the Tailwind 4 plugin provide Moraine’s CSS animations. The built-in keyframes and transform utilities read the duration variables shown below. Set these variables in CSS; the preset’s theme overrides cover design tokens, not animation controls.
Built-in Animation Utilities#
presetMoraine() and moraine/tailwind register the following animation utilities:
| Utility | Description | Iteration |
|---|---|---|
animate-mo-enter |
Composable entrance animation with opacity, scale, and translation. | 1 |
animate-mo-exit |
Composable exit animation for overlays and disclosures. | 1 |
animate-accordion-down |
Expand height from 0 to var(--mo-collapsible-content-height). |
1 |
animate-accordion-up |
Collapse height from var(--mo-collapsible-content-height) to 0. |
1 |
animate-spin |
Infinite 360-degree rotation for progress rings and spinners. | Infinite |
animate-carousel |
Continuous horizontal sliding translation (-100% to 100%). |
Infinite |
animate-shimmer |
Linear horizontal sweep for Skeleton’s gradient overlay. | Infinite |
animate-carousel-rtl |
Reverse horizontal sliding translation (100% to -100%). |
Infinite |
animate-carousel-vertical |
Continuous vertical sliding translation (100% to -100%). |
Infinite |
animate-swing |
Oscillating horizontal swing (-60% to 60%). |
Infinite |
animate-swing-vertical |
Oscillating vertical swing (60% to -60%). |
Infinite |
animate-elastic |
Horizontal stretch and snap translation. | Infinite |
animate-elastic-vertical |
Vertical stretch and snap translation. | Infinite |
animate-toast-bump |
Brief scale pulse when a toast updates. | 1 |
animate-toast-progress |
Toast countdown bar shrinking from full to empty width. | 1 |
Parametric Transform Utilities#
animate-mo-enter and animate-mo-exit read CSS variables that matching utility classes set. Combine the utilities to build custom entrance and exit motion without writing keyframes:
| Utility pattern | Target variable | Values | Example |
|---|---|---|---|
enter-opacity-<val> |
--mo-enter-opacity |
0–100 percentage |
enter-opacity-0, enter-opacity-50 |
exit-opacity-<val> |
--mo-exit-opacity |
0–100 percentage |
exit-opacity-0 |
enter-scale-<val> |
--mo-enter-scale |
Scale percentage or arbitrary | enter-scale-90, enter-scale-95 |
exit-scale-<val> |
--mo-exit-scale |
Scale percentage or arbitrary | exit-scale-95 |
enter-translate-x-<val> |
--mo-enter-translate-x |
Spacing or arbitrary | enter-translate-x-4, -enter-translate-x-2 |
enter-translate-y-<val> |
--mo-enter-translate-y |
Spacing or arbitrary | enter-translate-y-2, -enter-translate-y-4 |
exit-translate-x-<val> |
--mo-exit-translate-x |
Spacing or arbitrary | exit-translate-x-2 |
exit-translate-y-<val> |
--mo-exit-translate-y |
Spacing or arbitrary | exit-translate-y-2 |
enter-rotate-<val> |
--mo-enter-rotate |
Degrees or arbitrary | enter-rotate-12, -enter-rotate-45 |
exit-rotate-<val> |
--mo-exit-rotate |
Degrees or arbitrary | exit-rotate-12 |
Animation Durations and Easing#
Moraine defines a default duration and easing curve for each animation type. Keyframes that fit no named type (such as animate-accordion-down and animate-toast-bump) use the enter duration and curve, except animate-toast-progress, which sets its own duration per toast.
--mo-anim-durationoverrides every Moraine animation duration when defined.- When
--mo-anim-durationis unset, each animation uses its type-specific duration (enter,exit,loop, orspin). --mo-anim-easeoverrides the easing ofanimate-mo-enterandanimate-mo-exitin its scope. When it is unset, they read--mo-anim-ease-enterand--mo-anim-ease-exitrespectively, then fall back to the curves below. Set these variables on the animated element or a DOM ancestor. Portaled content cannot inherit from a trigger’s container, because the portal is outside it.- Easing curves:
enter:cubic-bezier(0.16, 1, 0.3, 1)(snappy ease-out)exit:cubic-bezier(0.7, 0, 0.84, 0)(accelerating ease-in)loop:ease-in-outspin:linear
animate-shimmer uses the loop duration with linear easing.
Disclosure Height Token#
Collapsible and Accordion measure their panel and set --mo-collapsible-content-height, in pixels, on the disclosure container (the Collapsible root or the Accordion item content). The animate-accordion-down and animate-accordion-up keyframes read this variable to animate between 0 and the panel’s natural height.
Reduced Motion#
To respect user preferences for reduced motion, pair animation utilities with motion-reduce:animate-none or motion-reduce:transition-none: