Gallery✨ Premium

Auto-play Slider

A slideshow that advances by itself: a bar fills up, the next slide glides in, and everything stops as soon as the mouse or the keyboard lands on it.

JSTimerProgress

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Gallery has 44 effects, including 6 free. Explore the category →

3 usage examples

This week's offers at the top of a bike shop — Auto-play Slider example 1

① This week's offers at the top of a bike shop

WhenUnder the Rouvelle shop menu, a full-width banner 136 px tall cycles through three offers: a gravel bike at 15% off, a workshop service, city helmets. Each slide is an image with a title and a button. The categories (road, gravel, city, kids) follow right below.
WhyThree sales messages fit in the space of one, without the visitor having to click. The progress bar shows how long is left before the change, and the hover pause keeps the offer they were reading from slipping away.
Settings--apl-max-width: none and height set by the scene (--apl-ratio: auto, 136 px container), transparent root. Three <img> (SVG illustrations) + text per slide, labels "1 of 3"… data-apl-interval="1300" sped up so the 2-second capture shows a change; 5000 to 6000 ms work better for real. In the capture the mouse passes over the banner: the bar stops there.
Recipe steps in cooking mode — Auto-play Slider example 2

② Recipe steps in cooking mode

WhenIn the Mitonelle app, a leek tart recipe shows the ticked ingredients on the left and, on the right, one large white card per step: "Step 2 of 5" then the instruction in big type. Steps move on by themselves while your hands are busy; the pause button and the orange arrows let you stay on a step or go back.
WhyHere the carousel is a step-by-step guide rather than a showcase: the text is the main element, the progress bar shows the reading time left, and pausing is a real need (a step takes longer than planned).
SettingsDefault 16/10 format across the whole column (--apl-max-width: none), slides on a white background (scene CSS), arrows grouped at the bottom right and tinted orange by the scene. data-apl-interval="1000" (the minimum, for the capture); count 15 to 30 s per step in real use.
Commitments rotating under the Pay button — Auto-play Slider example 3

③ Commitments rotating under the Pay button

WhenOn the Tissavelle (home linen) basket page, under the total and the "Pay €163" button, a small 182 × 86 px box rotates three commitments: secure payment, free returns within 30 days, shipping within 48 h. Each one is an icon and a single line.
WhyAt the moment of paying, these reminders reassure without pushing the button down: three messages take the space of one. Used as a small detail, the effect does not steal attention from the main button.
Settings--apl-ratio: 182/86, very light green background, 22 px arrows and a 22 px pause button placed at the bottom (scene CSS), 3 px green progress bar. data-apl-interval="1200" for the capture. The pause button stays visible: automatic playback must always be stoppable.

How it works

The .fx-0163-root root holds an .apl-carousel (a named region), an .apl-viewport window and an .apl-track in display:flex: each .apl-slide takes 100% of the width and the track moves by translateX(-100%) per slide in 0.5 s. An <img> placed in a slide covers it entirely (object-fit: cover); without one, the five indigo → amber demo gradients apply.

The script finds every .fx-0163-root on the page and gives each one its own timer, so two carousels on one page run independently. A requestAnimationFrame loop fills the .apl-progress bar from the time actually elapsed (steps of at most 50 ms per frame, so no jump when a hidden tab comes back); at 100% the next slide arrives and the bar starts over. Duration: data-apl-interval, 3000 ms by default, 1000 ms minimum.

Playback stops while the mouse is over the carousel, while keyboard focus is inside it, and when the carousel leaves the screen (the loop is actually stopped, not just hidden). The round button at the top right pauses or resumes; asking for playback with it overrides the hover pause. The ‹ › arrows and a horizontal drag of more than 50 px (finger or mouse) change slide and reset the bar.

Accessibility

  • Carousel roles: role="region" + aria-roledescription="carousel" and a name on the container; each slide is a role="group" announced as "slide, 2 of 5". These texts live in the HTML: translate them and update "X of N" if you change the number of slides.
  • Pause: a button named "Pause automatic playback" / "Resume automatic playback" depending on its state, plus a stop on hover, on keyboard focus and off screen. Hidden slides are inert: a link inside them cannot take focus.
  • Announcements: the track is aria-live="off" while playing (nothing is read every 3 s) and switches to polite once paused, so the slide chosen with the arrows is announced.
  • Reduced motion: under prefers-reduced-motion: reduce the carousel starts paused and slides change without gliding; arrows, swipe and the play button keep working.
  • Touch: Pointer Events with touch-action: pan-y on the window: a horizontal gesture changes slide, a vertical one scrolls the page as usual.

Browser compatibility

Dependency-free JavaScript (requestAnimationFrame, Pointer Events, IntersectionObserver) and the inert attribute (Chrome 102, Firefox 112, Safari 15.5 according to MDN). Measured in Chromium 151, Firefox 153 and WebKit 26.5 (Playwright): two copies with only the second one driven, playback that advances without hover and stops on hover, reduced motion, 390 px without horizontal scrolling, finger swipe (Chromium) without blocking vertical scrolling, 0 errors.

Chrome 102+✓ Full (measured)
Firefox 112+✓ Full (measured)
Safari 15.5+✓ Full (measured in WebKit)
Edge 102+✓ Full (Chromium engine)
Mobile iOS 15.5+✓ WebKit engine, not checked on a device
Android Chrome 102+✓ Full (touch measured)

Without JavaScript the first slide stays visible and the buttons do nothing. Before Safari 15.5 / Firefox 112, inert is ignored: everything works, but a link in a hidden slide can receive focus.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0163-root" data-apl-interval="3000">
  <div class="apl-carousel" role="region" aria-roledescription="carousel" aria-label="…">
    <div class="apl-viewport">
      <div class="apl-track" aria-live="off">
        <div class="apl-slide" role="group" aria-roledescription="slide" aria-label="1 of 5"><img src="…" alt="…"></div>
        …
      </div>
    </div>
    <div class="apl-progress" aria-hidden="true"></div>
    <button class="apl-toggle" type="button" aria-label="…" data-apl-label-pause="…" data-apl-label-play="…"><svg class="apl-icon-pause">…</svg><svg class="apl-icon-play">…</svg></button>
    <button class="apl-arrow apl-prev" type="button" aria-label="…">…</button>
    <button class="apl-arrow apl-next" type="button" aria-label="…">…</button>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Slide duration (HTML — data-apl-interval on .fx-0163-root) 3000 (ms) Time the bar takes to fill before the next slide. Minimum 1000 ms. For text people must read, aim for 5000 ms or more.
Maximum width (CSS — --apl-max-width) 640px The carousel takes its container's width up to this limit. none to fill the whole width.
Proportions (CSS — --apl-ratio) 16 / 10 Width/height ratio. auto if you set a height on the carousel yourself.
Slide content (HTML — .apl-slide) 5 gradients "Slide 1" to "Slide 5" Put an <img> in it (it covers the whole slide) and/or text. Add or remove slides freely, updating their "X of N" aria-label.
Pause button labels (HTML — data-apl-label-pause / data-apl-label-play) "Pause automatic playback" / "Resume automatic playback" Name read by screen readers depending on the state; translate it with the other labels.
Glide speed (CSS — .apl-track) transform .5s cubic-bezier(.25,.46,.45,.94) Duration and curve of the transition between two slides.
Bar colour (CSS — .apl-progress) gradient #6366f1 → #d946ef, 4 px Background and height of the progress bar at the bottom of the carousel.

FAQ

It moves as soon as the mouse leaves its frame. If it stays still, check that keyboard focus didn't stay on an arrow (Tab elsewhere to release it), that the button isn't showing "play", and that the system isn't set to "reduce motion": in that case it deliberately starts paused.
Yes. Only the visible slide is reachable by keyboard, the others are inert. When a visitor tabs to the link, playback pauses so they have time to activate it.
The carousel starts playing, except under reduced motion. To start paused, click the button from a script on load, but only if the carousel is not paused already (apl-paused class on .apl-carousel): otherwise that click would start playback for people using reduced motion. For example var r = document.querySelector('.fx-0163-root'); if (!r.querySelector('.apl-paused')) r.querySelector('.apl-toggle').click();. Arrows and swipe keep working.