A tiny, performant scroll animation library for Svelte.
Zero dependencies. Under 1KB gzipped.
npm install svelte-aos Add the CSS to your app. Import all or just what you need.
// Import everything
import 'svelte-aos/styles/full.css';
// Or selectively
import 'svelte-aos/styles/base.css'; // Required
import 'svelte-aos/styles/fade.css'; // OptionalPlace at the top of your layout or page for global configuration.
<script>
import { AOS } from 'svelte-aos';
</script>
<AOS options={{ /* config */ }} />Use attachments (Svelte 5.29+) or actions (Svelte 4+).
<!-- Svelte 5.29+ -->
<div
data-aos="fade-up"
{@attach aosAttachment({ animation: 'fade-up' })}>
Hello
</div>
<!-- Svelte 4 to 5.28 -->
<div data-aos="fade-up" use:aosAction>
Hello
</div>The data-aos attribute enables animation on first page load when the element is already
visible. Without it, elements only animate when scrolled into view.
Opacity transitions with optional movement
Scale transformations
3D rotation effects
Pure translation without opacity
lineareaseease-inease-outease-in-outease-in-backease-out-backease-in-out-backease-in-sineease-out-sineease-in-out-sineease-in-quadease-out-quadease-in-out-quadease-in-cubicease-out-cubicease-in-out-cubicease-in-quartease-out-quartease-in-out-quartGlobal configuration component. Place at root level.
<AOS
options={{
offset: 120,
delay: 0,
duration: 400,
easing: 'ease',
once: false,
disable: false,
threshold: 0.1,
anchorPlacement: 'top-bottom'
}}
/>Svelte 5 attachment for individual elements.
<div
{@attach aosAttachment({
animation: 'fade-up',
delay: 150,
duration: 400,
once: true
})}
>Svelte action for individual elements.
<div
use:aosAction={{
animation: 'fade-up',
delay: 150,
duration: 400,
once: true
}}
>Disable animations globally or conditionally.
<AOS options={{
// Device type
disable: 'mobile' // 'phone' | 'tablet'
// Boolean
disable: true
// Function
disable: () => window.innerWidth < 768
}} />Only import the animations you need to minimize bundle size.
base.css Core setup, CSS variables, reduced motion ✓ Requiredfade.css fade, fade-up, fade-down, etc. Optionalzoom.css zoom-in, zoom-out variants Optionalflip.css flip-up, flip-down, etc. Optionalslide.css slide-up, slide-down, etc. Optionaleasings.css Custom easing functions Optionalfull.css Everything bundled Convenience