Skip to content

slider

aa-slider turns a list of [aa-slider-item] elements into a seamless looping carousel powered by GSAP’s horizontalLoop helper. Modes are space-separated tokens inside the attribute value; combine freely.

aa-slider modes:

TokenEffect
(empty)Basic slider; prev/next + thumb buttons advance one slide. No autoplay, no drag.
draggableMouse + touch drag with InertiaPlugin throw, snaps to nearest slide.
centerCenters the active slide horizontally in the container.
noneDon’t init at this breakpoint. Combine with the | shorthand (splits at md) or any of the -sm / -md / -lg / -xl suffix attributes for responsive on/off.

Autoplay is a separate, standalone attribute — aa-autoplay — so the same configuration shape applies uniformly to sliders and tabs and aa-delay keeps its meaning of “tween start delay” everywhere.

aa-autoplay valueEffect
(attribute absent)No autoplay.
(empty: aa-autoplay)Autoplay enabled at the init default interval (autoplay.interval, default 4s). No hover pause.
<number> (e.g. "3")Autoplay with the given dwell in seconds.
hover-pauseAdd hover-pause: mouseenter pauses, mouseleave resumes (non-touch only).
<number> hover-pauseBoth — e.g. aa-autoplay="3 hover-pause".
noneOpt out (e.g. aa-autoplay="3|none" — autoplay on desktop, off on mobile).
<div aa-slider="draggable center" aa-duration="0.6" aa-autoplay="3 hover-pause"></div>
<!-- Bento on desktop, autoplay carousel on mobile -->
<div aa-slider="none|" aa-autoplay="none|3"></div>
AttributeWhat it marks
aa-sliderSlider root.
aa-slider-itemEach slide. Keep it as a thin flex wrapper — put visual styling on a child element so borders/shadows don’t get caught by the slider’s transform math.
aa-slider-prevPrevious-slide button.
aa-slider-nextNext-slide button.
aa-slider-buttonThumbnail / pagination button. Index inferred from DOM order.
aa-slider-targetWhen set on an external aa-slider-button, references the slider’s id.
aa-slider-currentElement whose text content reflects the current 1-based slide index.
aa-slider-totalElement whose text content reflects the total slide count.
aa-slider-progressInside aa-slider-button, fills over the resolved aa-autoplay interval. Value is width (default), height, or circle. For circle, mark an SVG (or place an SVG inside the marked element) — the lib finds the inner <circle> and tweens its stroke-dashoffset from full circumference to zero.
AttributeDefaultNotes
aa-duration(init)Seconds for each slide transition.
aa-autoplay(off; init interval when present)See the autoplay table above. Drives the per-slide dwell + progress-bar fill.
aa-ease(init)Any GSAP ease — used for transitions and progress bars.

gsap, ScrollTrigger, Draggable, InertiaPlugin.

aa-animate elements inside an [aa-slider-item] are automatically driven by slide activation: they play when the slide becomes active and reverse when it becomes inactive. No aa-trigger attribute needed — the slider emits slide-active / slide-inactive events on each slide and the closest container ancestor is the inferred trigger.

<div aa-slider aa-autoplay="3">
<div class="track">
<div aa-slider-item>
<div class="slide-card">
<h2 aa-animate="fade-up">Headline</h2> <!-- inferred: event:slide-active -->
</div>
</div>
</div>
</div>

If you need to opt out — e.g. an animation inside a slide that should still respond to scroll position — set aa-trigger="scroll" explicitly to override the inference.

When the slider has focus, Arrow Left / Arrow Right step backwards / forwards, Home jumps to the first slide, End to the last. The slider root gets tabindex="0" automatically.

Slide 1
Slide 2
Slide 3
Slide 4
Slide 5
01/05

Live demo — centered, autoplay with hover-pause, draggable, with thumb-bullets and progress

Section titled “Live demo — centered, autoplay with hover-pause, draggable, with thumb-bullets and progress”

A slider with aa-slider="draggable center" and aa-autoplay="3 hover-pause" shows multiple slides at once with the active one centered. Hover pauses the autoplay; mouseleave resumes. Each thumb has an inner [aa-slider-progress] that fills during the dwell.

Slide A
Slide B
Slide C
Slide D
Slide E
Slide F
Slide G

aa-slider-progress="circle" on an SVG (or a wrapper containing one) animates the inner <circle>’s stroke-dashoffset to draw the ring during the dwell. The user controls the visual — viewBox, radius, stroke colour and width — entirely via the SVG markup and CSS.

Slide 1
Slide 2
Slide 3
Slide 4

Live demo — animations triggered on slide activation

Section titled “Live demo — animations triggered on slide activation”

Each slide contains a heading and paragraph with plain aa-animate="fade-up" — no aa-trigger attribute. Because they live inside [aa-slider-item], they’re inferred to use event:slide-active: they fade up on activation and reverse on deactivation.

Discover the moment a slide takes the stage

Headlines slide up by line when the slide becomes active and reverse on the way out.

Iterate without rewriting the trigger

Same primitive — different trigger, picked up automatically from the slider-item ancestor.

Ship with paired forward and reverse events

Names ending in -active auto-pair with -inactive so the timeline reverses cleanly.