Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 29, 2026·3 min de lecture

Embla Carousel — Lightweight Carousel Library with Fluid Motion

A dependency-free carousel library with precise swipe behavior and plugin support for React, Vue, Svelte, Solid, and vanilla JavaScript.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Embla Carousel Overview
Commande d'installation directe
npx -y tokrepo@latest install 1380500b-5af4-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Embla Carousel is a lightweight, dependency-free carousel engine designed around natural scroll physics and precise swipe handling. The core library is framework-agnostic, with official wrapper packages for React, Vue, Svelte, and Solid. It uses CSS flexbox for layout and provides a plugin system for autoplay, class names, and other behaviors.

What Embla Carousel Does

  • Creates horizontal and vertical carousels with smooth scroll physics
  • Handles touch, mouse, and trackpad swipe gestures with configurable friction
  • Supports loop, fade, and variable-width slide configurations
  • Provides a plugin API for autoplay, class names, wheel gestures, and auto-height
  • Exposes a programmatic API for navigating, observing, and controlling the carousel

Architecture Overview

The core engine calculates slide positions and manages scroll animation using requestAnimationFrame. It reads CSS flexbox layout measurements to determine slide widths and gaps, then translates the container element along the scroll axis. Swipe velocity is tracked to produce momentum-based scrolling that feels natural. The plugin system hooks into lifecycle events (init, select, settle, scroll) so extensions like autoplay can react to carousel state changes without modifying the core.

Installation & Configuration

  • Install the framework wrapper: npm install embla-carousel-react (or -vue, -svelte, -solid)
  • Pass the ref from the hook to a container element with overflow hidden
  • Configure options like loop, axis, dragFree, and startIndex via the hook
  • Add plugins by passing them as the second argument to the hook
  • Use the emblaApi object to listen for events and control navigation

Key Features

  • Zero dependencies with a core bundle under 3 KB gzipped
  • Framework wrappers for React, Vue, Svelte, Solid, and vanilla JS
  • Plugin system with official autoplay, class names, fade, auto-height, and wheel plugins
  • Right-to-left (RTL) layout support
  • Supports variable-width slides and multi-slide views without configuration

Comparison with Similar Tools

  • Swiper — more built-in features (pagination, navigation) but significantly larger bundle
  • Splide — similar feature set; slightly larger with more out-of-the-box UI components
  • Keen Slider — comparable size and approach; smaller community
  • Slick — jQuery-based; legacy choice not suited for modern React projects
  • Flickity — mature library; no native React integration

FAQ

Q: How do I add autoplay? A: Install embla-carousel-autoplay and pass it as a plugin: useEmblaCarousel([Autoplay()]).

Q: Can I make slides different widths? A: Yes. Set each slide to its desired CSS width. Embla reads the actual rendered dimensions from the DOM.

Q: Does it support infinite looping? A: Yes. Set the loop option to true. The library clones slides internally to create a seamless wrap.

Q: How do I add previous/next buttons? A: Use the emblaApi.scrollPrev() and emblaApi.scrollNext() methods attached to button click handlers.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires