Animations & Micro-interactions

Everything on this page moves only transform and opacity - this isn't a preference, it's a condition for smoothness. Section 1 explains why. Ready-made effects: micro-interactions and entrance animations.

1. Why only two properties

The browser draws a frame in three steps: it computes layout (where everything is), paints pixels, and composites layers. The animated property decides how much of that has to repeat sixty times a second.

You animate What has to recompute Result
width, height, top, margin Layout of the whole page, painting, compositing forbidden Resizing one element shifts its neighbors, so the browser recomputes layout from scratch.
box-shadow, background-color, border-radius Painting and compositing avoid Layout stays put, but the pixels have to be repainted.
transform, opacity Compositing only allowed The GPU handles it, with no involvement from the main thread.

How to work around this when you really need to

A shadow that's supposed to grow is done with a second layer holding a ready-made shadow and animating its opacity - that's how .hover-gpu-shadow works. Expanding a height "to however much it takes" is handled by .grid-expand, animating grid-template-rows. So the rule isn't a limit on what's possible, just a choice of approach.

2. Entrance animations

An element waits invisible, and once it scrolls into view, a script gives it the .is-visible class and it smoothly appears. Detection is handled by an intersection observer - not a scroll event, so nothing gets computed on every pixel of scrolling. In Chrome/Edge 145+ CSS does it alone through animation-trigger: the element starts its own entrance, the script creates no observer at all, and the .is-visible class does not appear. So there the animations also work without molique-script.js.

<!-- .animate is REQUIRED - it's what hides the element at the start -->
<div class="animate fade-in-up">Slides in from the bottom</div>

<!-- Cascade: successive elements with a delay -->
<div class="animate fade-in-up">First</div>
<div class="animate fade-in-up delay-100">Second</div>
<div class="animate fade-in-up delay-200">Third</div>
Class Role What it does
.animate Base Hides the element and sets up the transition. Without it, the direction does nothing - see pitfall #1.
.fade-in Direction Just a fade-in, no movement.
.fade-in-up Direction Slides in from below - the most common choice. Also: .fade-in-down, .fade-in-left, .fade-in-right.
.zoom-in Direction The element "arrives" by scaling up from 95%.
.reveal-blur Direction Sharpens from a blur.
.reveal-scale Direction A stronger scale entrance than .zoom-in.
.delay-100 - .delay-500 Modifier A delay in steps of 100 ms. For building a cascade across a row of cards.
.is-visible State Set by the script once the element scrolls into view. You don't write it yourself. In Chrome/Edge 145+ CSS does the entrance and this class is absent - do not build your own styles on it.

A JavaScript-free variant

.scroll-reveal does the same thing, but driven by scroll position, not a script. The animation's progress matches how much of the element is visible, so you can scroll back up and the effect reverses. Requires a newer browser; in an older one, the element is simply visible right away.

<div class="scroll-reveal">Appears as you scroll</div>

3. Micro-interactions

A reaction to hovering. They all work on any element - a card, a button, an image - and can be combined.

hover-spring + hover-gpu-shadow
hover-scale
hover-tilt
Class Effect JS
.hover-spring A springy bounce. no
.hover-scale Enlargement. Strength: --hover-scale. no
.hover-shadow Lift with a shadow. Height: --hover-y. no
.hover-gpu-shadow A growing shadow without animating box-shadow - a second layer changes opacity. no
.hover-tilt A fixed 3D tilt. no
.tilt-card A tilt that follows the cursor. On a touch device the module disables itself - saves battery. yes
.hover-filter-none Removes a filter on hover - a gray logo that gains color under the cursor. no
.hover-opacity-100 A dimmed element regains full opacity. no
.ken-burns A slow zoom into a photo inside a container. Works on <img> and .bg-image. no
.shake A shake - an error signal, e.g. for a rejected form. Plays once. no

Border effects

A border that draws itself on hover. Two rounded variants and two with sharp corners - they differ not just in look but in mechanism, which matters when combining them with a background.

Class Look Mechanism
.hover-border-draw Rounded, unfolds from the center. Its own ::before - doesn't touch the element's background.
.hover-border-trace Rounded, a light traces the outline. Also a ::before.
.hover-border-draw-2 Sharp corners, drawn side by side. Four gradients in the element's background-image - see pitfall #3.
.hover-border-trace-2 Sharp corners, the outline is traced. Same as above.

Border color

All four take their color from --hover-border-color, defaulting to --primary. Set it when the element already has the brand color - otherwise the border will be invisible against a background of the same color.

4. Motion and accessibility

Some people get dizzy or nauseous from animation - the vestibular system reacts to motion on screen the same way it reacts to motion of the body. That's why operating systems have a "reduce motion" setting, and the browser passes it through as prefers-reduced-motion.

Type of motion With reduced motion
A hover response Stays. It's short and triggered by the user.
Entrance animations The element appears with no motion.
Continuous background motion Stopped. Applies to .bg-blobs, among others - the animation stops, the shape stays.

Writing your own effect

The framework doesn't mute animations globally - each component does it for itself, since not every motion needs to be stopped. When adding your own continuous animation, write its escape hatch: @media (prefers-reduced-motion: reduce) and animation: none.

5. Pitfalls

1 A direction without the .animate class

.fade-in-up only sets the starting offset. It's .animate that hides the element and defines the transition - without it, the element is visible right away and nothing happens. A misleading symptom, since the page looks correct, just "without the animation."

<!-- WRONG - missing the base -->
<div class="fade-in-up">…</div>

<!-- RIGHT -->
<div class="animate fade-in-up">…</div>
2 An entrance animation on content that's visible right away

A hero heading with .animate starts invisible and waits for the script. If JavaScript doesn't run - an error in another file, a slow connection, a browser block - the content stays invisible permanently. Above the fold, use animation sparingly, and leave your most important message static. In Chrome/Edge 145+ this problem is gone (CSS starts the entrance), but it still applies in Firefox and Safari.

3 The -2 border invisible on a colored background

The sharp-corner variants draw their lines with gradients in the element's background-image. The background-color is untouched, so they technically work - but the line defaults to --primary, which is invisible on a .btn-primary button. Set --hover-border-color to a contrasting color.

<button class="btn-primary hover-border-draw-2"
        style="--hover-border-color: #fff;">White border</button>
4 A delay cascade on a long list

The .delay-* classes end at 500 ms, and that's not an oversight. With twenty cards and an increasing delay, the last one appears after two seconds - to the user it looks like a stuttering page, not an effect. Use a cascade for three or four elements in a single row.

5 Animating a property outside the pair

transition: all looks innocent, but it also covers width, height, and box-shadow - pulling in a layout recalculation through the back door. List properties explicitly. When an effect you need requires a forbidden property, look for a workaround from section 1: an opacity layer instead of a shadow, a grid instead of a height.

6. Where to find the rest

Some effects are documented where they belong thematically - so the same thing isn't explained twice.

Looking for Where
A gradient in letters, a typewriter, a highlighter, underlines Typography & Colors
Parallax, stacked sections Sections & Hero
Smooth height expansion (.grid-expand) Modals, Tabs & Accordions
Animated background blobs (.bg-blobs) Examples: blobs
Magnetic button, speed dial Widgets