EOS UI
Components

Carousel

A framework-agnostic Web Component for cycling through content with navigation, indicators, autoplay, and touch gestures.

Import

import '@eosjs/ui/carousel';

Introduction

Carousel presents a sequence of slides with native keyboard navigation, touch gestures, optional autoplay, and clickable progress indicators. Slides are passed through the default slot, so each slide can contain any HTML or Web Component content.

When the operating system requests reduced motion, autoplay stays paused and slide transitions become effectively instant. Manual navigation remains available.

Basic Usage

Basic usage

SLIDE / 01
SLIDE / 02
SLIDE / 03
Use the arrows, swipe, or keyboard focus to navigate. Autoplay pauses after manual interaction.

API

Generated from custom-elements.json for eos-carousel.

Attributes

NameTypeDefaultDescription
autoplay———
interval———
loop———
show-navigation———
initial-index———
indicator-position———
indicator-style———
virtual-threshold———

Events

NameTypeDescription
slide-activeCustomEvent—
slide-clickCustomEvent—
changeCustomEvent—

Methods

NameSignatureDescription
next——
prev——
goTo——
play——
setSlideLoading—设置当前 slide 为加载中状态(波纹动画) 调用 startSlideProgress 时会自动结束加载状态
startSlideProgress—开始当前 slide 的进度倒计时
stopSlideProgress——
pauseSlideProgress—暂停当前 slide 的进度并保留已完成的进度
resumeSlideProgress—恢复当前 slide 从暂停位置继续进度
pause——
updateProgress—手动同步进度显示(用于视频播放进度)

Attributes

AttributeTypeDefaultDescription
autoplaybooleanfalseAutomatically advance through the slides
intervalnumber2000Autoplay interval in milliseconds; values below 1000 are clamped
loopbooleanfalseContinue from the first slide after the last slide
show-navigationbooleantrueShow previous and next controls
initial-indexnumber0Initial zero-based slide index
indicator-positiontop | bottom | left | rightbottomPosition of the progress indicators
indicator-styledefault | dots | tiktokdefaultVisual style of the progress indicators
virtual-thresholdnumber8Enable three-slot rendering after this many slides

Events

EventWhen it firesevent.detail
changeThe active slide changes{ currentIndex, previousIndex }
slide-activeA slide becomes active{ index, slide, mediaType }
slide-clickA slide is clicked{ index }

Methods

Carousel exposes imperative controls through its DOM element:

const carousel = document.querySelector('eos-carousel');

carousel.play();
carousel.pause();
carousel.next();
carousel.prev();
carousel.goTo(2);

Slots

Use the default slot for any slide content:

<eos-carousel autoplay loop interval="3000">
  <img src="/cover-01.jpg" alt="Mountain landscape" />
  <img src="/cover-02.jpg" alt="Coastal landscape" />
</eos-carousel>

CSS custom properties

PropertyDefaultDescription
--carousel-height400pxHeight of the carousel host
--progress-bar-height3pxIndicator height in pixels
--progress-bar-gap3pxGap between indicators
--progress-bar-colorrgba(255, 255, 255, 0.3)Inactive indicator color
--progress-bar-active-colorrgba(255, 255, 255, 1)Active indicator color
--control-bgrgba(0, 0, 0, 0.3)Navigation control background
--control-hover-bgrgba(0, 0, 0, 0.5)Navigation control hover background

Framework integration

Carousel is a standard custom element. The same markup works in React, Vue, Angular, and native HTML; framework listeners receive the native DOM and CustomEvent APIs.

<eos-carousel autoplay loop interval="3000">
  <div>Slide one</div>
  <div>Slide two</div>
</eos-carousel>

On this page