Carousel
Basic Structure
Every carousel needs .embla, .embla-viewport, .embla-container, and .embla-slide.
.embla
Columns
Control how many slides are visible with .embla-cols-{1-6}. Responsive variants available.
.embla-cols-3
Peek & Spacing
By default, 15% of the next slide peeks. Override with CSS variables.
.embla-no-peek
--embla-slide-spacing
.embla-g-{0-5}
Spacing scale
Gap helpers mirroring Bootstrap's $spacers map. Sets --embla-slide-spacing.
Class Value
.embla-g-0 0
.embla-g-1 0.25rem
.embla-g-2 0.5rem
.embla-g-3 1rem (default)
.embla-g-4 1.5rem
.embla-g-5 3rem
Options
All options are set via data-* attributes on the .embla element.
Core options
Attribute Default Description
data-loop false Infinite loop scrolling
data-align start Slide alignment: start, center, end
data-skip-snaps false Allow skipping snaps on drag
data-drag-free false Free-form dragging (momentum scroll)
data-contain-scroll trimSnaps Scroll containment behavior
data-loop="true"
Autoplay & Auto Scroll
Two plugins: autoplay (slide by slide) and autoscroll (continuous movement).
Autoplay options
Attribute Default Description
data-autoplay false Enable autoplay plugin
data-autoplay-delay 4000 Delay between slides (ms)
data-stop-on-interaction true Stop on user interaction
data-stop-on-mouse-enter false Pause on hover
Auto Scroll options
Attribute Default Description
data-autoscroll false Enable continuous scroll
data-autoscroll-speed 1 Scroll speed multiplier
data-autoscroll-direction forward Scroll direction: forward (left) or backward (right)
data-stop-on-interaction true Stop on user interaction
data-stop-on-mouse-enter false Pause on hover
data-autoplay="true"
Live demo
Height & Width
Control slide dimensions with utility classes.
Height & width classes
Class Effect
.embla-h-sm Slide height: 150px
.embla-h-md Slide height: 250px
.embla-h-lg Slide height: 350px
.embla-h-xl Slide height: 450px
.embla-auto-height Height adapts to content (min-height from above)
.embla-auto-width Slides size to their content width
Responsive Disable
Disable the carousel at a breakpoint and switch to a CSS grid layout.
.embla-{breakpoint}-disable
CSS Variables
All styling is driven by CSS custom properties on .embla.
Available variables
Variable Default Description
--embla-slide-spacing 1rem Gap between slides
--embla-slide-peek 15% How much of the next slide peeks
--embla-cols 1 Number of visible columns (set by classes)
--embla-slide-height — Fixed slide height (set by .embla-h-* classes)
On this page