Embla Carousel Fade Hero Slider — Free Crossfade Banner Snippet

Embla Carousel Fade Hero Slider · Carousels · Plain HTML, CSS & JS · Live preview

What's included

Features

Official Fade plugin
Crossfades without changing markup.
Swipe to fade
Dragging still changes slides.
Progress-line indicators
CSS animation synced to the autoplay delay.
Pause-aware animation
animation-play-state follows autoplay.
Clean tab order
Hidden slides get aria-hidden and tabIndex -1 links.
Hover and focus pause
For mouse and keyboard users.
Reduced-motion aware
No autoplay for those who ask.
Readable overlays
Gradient scrim behind the copy.

About this UI Snippet

Embla Carousel Fade Hero — Crossfading Slides With Honest Controls

Screenshot of the Embla Carousel Fade Hero Slider snippet rendered live

Hero banners usually crossfade rather than slide: a full-bleed image moving sideways feels busy, while a fade feels calm and editorial. Embla's official Fade plugin turns any Embla carousel into a crossfade without changing the markup.

Fade is a plugin, the structure stays

EmblaCarouselFade() is added to the plugins array next to Autoplay. The slides are still a normal flex row inside the container; the plugin positions each slide over the first and animates opacity instead of translating the container. Dragging still works: a swipe crossfades to the next slide. The duration option controls the speed of the fade.

Indicators that show time

The three line indicators double as progress bars. The active one plays a CSS scaleX animation whose length comes from a --efh-delay custom property set from the same DELAY constant used by Autoplay. Toggling aria-selected off and on (with a forced reflow in between) restarts the animation on each slide change. When autoplay stops, an is-paused class pauses the animation with animation-play-state.

Hidden slides mustn't be focusable

A fading carousel keeps every slide in the DOM, just transparent. Without care, pressing Tab would move focus to a call-to-action link on an invisible slide. On every change the snippet sets aria-hidden on inactive slides and removes their links from the tab order.

Pausing

Autoplay pauses on hover (stopOnMouseEnter), on keyboard focus, and doesn't start for users who prefer reduced motion. Legibility comes from a left-to-right gradient overlay so the copy stays readable over any photo.

Step by step

How to Use

  1. 1
    Load Embla and pluginsInclude the Embla core, Fade and Autoplay UMD builds.
  2. 2
    Paste the snippetA hero with three crossfading slides starts playing.
  3. 3
    Use the indicatorsClick a line to jump; the active line fills over the slide's duration.
  4. 4
    Hover or tab inAutoplay and the progress line pause.
  5. 5
    Change timingEdit DELAY for autoplay and duration for fade speed.

Real-world uses

Common Use Cases

Calm hero for a retail brand
Rotate three seasonal campaigns with a slow crossfade instead of a sideways slide, which feels busy over full-bleed photography. Replace the slide images and the efh-copy captions with your campaign art.
Hotel and restaurant atmosphere
Let rooms, dishes and terraces dissolve into one another above the fold. The progress-line indicators show guests how long each scene stays, without needing arrows or counters.
Editorial feature banner
Highlight the week's lead stories with a headline and a call to action per slide. Hidden slides are removed from the tab order, so keyboard users never land on an invisible link.
Launch story in three beats
Introduce a launch as problem, product and offer, each on its own faded slide. Hovering or focusing pauses autoplay, so people can finish reading before the next slide arrives.
Event and conference banner
Open an event site with venue, speaker and highlight photos crossfading beneath one short headline per slide, so the calm transition suits a formal, premium tone for conferences and galas.
Related: Embla Autoplay Progress
A sliding version with a progress bar: Embla Carousel Autoplay with Progress Bar and Pause Control.
Related: Caption Crossfade Carousel
A dependency-free crossfade: Caption Crossfade Carousel.

Got questions?

Frequently Asked Questions

Load embla-carousel-fade and pass EmblaCarouselFade() in the plugins array. Keep the normal viewport, container and slide markup; the plugin handles positioning and opacity.

Yes. Dragging moves between slides, which crossfade rather than slide. Set watchDrag: false in the options if you want to disable it.

Use Embla's duration option. Lower values are faster; the snippet uses 30.

Fading keeps all slides in the DOM. Without aria-hidden and tabIndex -1 on inactive slides, keyboard users could tab to invisible links and screen readers would read every slide.

A CSS custom property holds the same delay value used by the Autoplay plugin, and the active line runs a linear scaleX animation of that length. Autoplay stop and play events toggle a paused class that pauses the animation.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Paste this snippet into an AI assistant like Claude and ask it to explain how the Fade plugin changes Embla's behaviour and why hidden slides need aria-hidden. Ask it to add a subtle Ken Burns zoom on the active image, text that animates in after each fade, or a video background for one slide. It can also check the contrast of the text over your own photos.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a full-width hero banner carousel with Embla Carousel v8 plus its Fade and Autoplay plugins (loaded from a CDN as UMD) in plain HTML, CSS and JavaScript.

Requirements:
- Three slides with a background photo, gradient scrim, eyebrow text, heading, paragraph and call-to-action link.
- Crossfade between slides with the Fade plugin, looping, with dragging still possible.
- Autoplay every five seconds, pausing on hover and when keyboard focus is inside, and not starting for users who prefer reduced motion.
- Line-shaped indicator buttons; the active one fills over the autoplay delay using a CSS animation whose duration comes from a custom property, restarts on each slide change and pauses while autoplay is stopped.
- Mark inactive slides aria-hidden and remove their links from the tab order.
- Adjust spacing and heading size for small screens.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Source Code

<section class="efh" aria-roledescription="carousel" aria-label="Collection highlights">
  <div class="efh-viewport" id="efhViewport">
    <div class="efh-container">
      <div class="efh-slide" role="group" aria-roledescription="slide" aria-label="1 of 3">
        <img src="https://picsum.photos/id/1068/1600/900" alt="">
        <div class="efh-copy"><span>Autumn 26</span><h2>Made for long walks</h2><p>Waxed cotton, recycled wool and boots that last a decade.</p><a href="#" class="efh-cta">Shop the collection</a></div>
      </div>
      <div class="efh-slide" role="group" aria-roledescription="slide" aria-label="2 of 3">
        <img src="https://picsum.photos/id/1029/1600/900" alt="">
        <div class="efh-copy"><span>Workshop</span><h2>Repaired, not replaced</h2><p>Send any piece back and we'll fix it for free, for life.</p><a href="#" class="efh-cta">How repairs work</a></div>
      </div>
      <div class="efh-slide" role="group" aria-roledescription="slide" aria-label="3 of 3">
        <img src="https://picsum.photos/id/1044/1600/900" alt="">
        <div class="efh-copy"><span>Journal</span><h2>Notes from the coast</h2><p>A week of field testing in wind, rain and very little sun.</p><a href="#" class="efh-cta">Read the story</a></div>
      </div>
    </div>
  </div>
  <div class="efh-nav" id="efhNav" role="tablist" aria-label="Choose slide"></div>
</section>