Embla's API · native scroll

A carousel on the browser's own scroll.

Spill has Embla Carousel's API, options, events and plugins — and nothing moves with transforms. The viewport really scrolls, so a finger, a trackpad, the keyboard and find-in-page all work as they do on any page. No dependencies, no stylesheet.

npm install @bozdev/spill

Three steps

Markup you already write, the look in your CSS, one call.

1 Install

npm install @bozdev/spill

Or a <script> tag — every way.

2 Markup and CSS

<div class="viewport">
  <div class="container">
    <div class="slide">1</div>
    <div class="slide">2</div>
    <div class="slide">3</div>
  </div>
</div>
.container { display: flex; gap: 1rem; }
.slide { flex: 0 0 80%; min-width: 0; }

3 Call it

import Spill from "@bozdev/spill";

const api = Spill(document.querySelector(".viewport"));
api.on("select", () => console.log(api.selectedScrollSnap()));

Or no script at all: by attributes.

Why native scroll

Carousels move a track with transform and rebuild scrolling in JavaScript. That was the dependable way when they were written. Today the browser does it — and does it better where it matters most: under a finger.

Native scroll (Spill)Transform (Embla)
A finger's momentum, iOS bounceThe browser's ownImitated
Trackpad, shift + wheelWorksNeeds a plugin
The keyboard's focus brings a slide inBy itselfHandled separately
Find in page reaches a slideYesNo
Before or without JavaScriptScrollable, readableA clipped row
SnappingCSS scroll snapJS physics

The whole comparison, and what Spill leaves out

Small

The browser does the snapping, the momentum and a finger's drag, so there is less to ship. Minified and gzipped:

Spill, the core4.9 KB
Embla, the core (8.6.0)7.2 KB
Spill, everything (the core, attributes, three plugins)8.0 KB

Examples

Each one live, with its code.

All examples