Aero
A small CSS animation library with an optional 6 KB script. Add a class, get the motion. It looks the same in every modern browser.
npm i https://github.com/thinair-studios/aero/archive/refs/tags/v2.0.0.tar.gzEntrances
Add aero-enter plus a variant. The element stays hidden until it scrolls into view, then plays once. Give a parent aero-in yourself and its children play on load, as the hero above does.
<h2 class="aero-enter aero-fade-up">Rises in when it comes into view</h2>aero-fade-upaero-fade-downaero-fade-leftaero-fade-rightaero-fade-inaero-scale-upaero-grow-upaero-grow-rightaero-fan-leftaero-fan-rightaero-lift<div class="aero-enter aero-grow-up" style="transform-origin: 50% 100%">...</div>
<div class="aero-enter aero-fan-left">...</div>Presets
Speed and easing are classes. Each tile below uses the same fade-up with a different preset.
aero-fastaero-slowaero-sloweraero-ease-expoaero-ease-backaero-ease-spring<div class="aero-enter aero-fade-up aero-slow aero-ease-back">...</div>Stagger
Children of aero-stagger start one after another, --aero-stagger apart (80ms by default).
1234<ul class="aero-stagger" style="--aero-stagger: 120ms">
<li class="aero-enter aero-scale-up">...</li>
<li class="aero-enter aero-scale-up">...</li>
</ul>Scroll-linked
Add aero-scrub to any variant and the animation follows the scroll position instead of time. --aero-scrub-range reads like animation-range. The same markup works in every browser: where CSS scroll timelines exist they run it, and elsewhere aero.js drives the identical animation.
The bar at the top of this page is aero-scrub aero-scrub-root with its own scaleX keyframes.
<div class="aero-scrub aero-fade-up" style="--aero-scrub-range: entry 0% entry 80%">...</div>
<div class="aero-scrub aero-pass" style="--aero-scrub-range: cover 0% cover 100%">...</div>
<div class="aero-scrub aero-fan-left" style="--aero-scrub-range: entry 25% cover 50%">...</div>
<!-- page progress bar -->
<style>
@keyframes progress { from { transform: scaleX(0) } to { transform: scaleX(1) } }
</style>
<div class="aero-scrub aero-scrub-root"
style="animation-name: progress"> <!-- no range: the whole page --></div>aero-fade-up
entry 0% entry 80%aero-pass
cover 0% cover 100%aero-fan-left
entry 25% cover 50%Hover
Only transform animates. Keyboard focus triggers the same motion as hover, and on touch screens hover movement is cancelled so a tap does not leave anything stuck.
Self-triggered
The element you hover is the one that moves. Tab to a card to see focus do the same.
aero-hover-lift
16px upaero-hover-lift-sm
8px upaero-hover-lift-lg
32px upaero-hover-scale
grows 3%aero-hover-rise
lifts and grows togetheraero-hover-shift
any move plus scale<a class="aero-hover-lift aero-hover-lift-lg">...</a>
<a class="aero-hover-scale">...</a>
<a class="aero-hover-rise">...</a>
<a class="aero-hover-shift" style="--aero-hover-x: 8px; --aero-hover-y: 8px">...</a>Group-triggered
Hover or focus anywhere in an aero-hover-group and its aero-hover-target moves. The arrow nudges when the whole link is hovered.
Read the guide
The card stays put, the arrow moves.
Continue →Image rises
The block lifts and grows, the text stays.
<a class="aero-hover-group" href="/guide">
Continue
<span class="aero-hover-target aero-hover-nudge">→</span>
</a>Cursor
aero.js tracks the pointer over any aero-cursor element and writes --aero-cursor-x, -y, -cx, -cy and -active. Effects inside it read those. data-aero-smoothing sets how far the values lag behind the pointer. Move your mouse over the panel.
aero-tilt
Tilts toward the pointer.aero-spotlight
A soft light follows the pointer.<div class="aero-cursor" data-aero-smoothing="0.18">
<div class="aero-tilt">Tilts toward the pointer</div>
<div class="aero-spotlight" style="--aero-spotlight-color: rgb(64 130 109 / 0.22)">A soft light</div>
<div class="aero-parallax aero-parallax-lg">Moves with the pointer</div>
<div class="aero-parallax aero-parallax-xl">Moves further</div>
</div>Prefixes
Every class works as aero-... or the short ae-.... This card uses only ae- classes.
ae-enter ae-scale-up ae-hover-rise
Same effects, shorter names.<div class="ae-enter ae-scale-up ae-hover-rise">...</div>Reduced motion
Motion plays by default, even when the visitor has turned on "Reduce motion", because many people use that setting to calm the operating system and not to switch off a site. To respect it, add aero-reduce-motion to <html>. Visitors who prefer reduced motion then see everything at once and still, and aero.js stops driving anything.
The class only has an effect if your operating system is set to prefer reduced motion. Otherwise toggling it changes nothing.
<html lang="en" class="aero-reduce-motion">