npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@smartimpact-it/modern-slick-carousel

v4.0.0

Published

Modern, jQuery-free TypeScript port of slick-carousel — the last carousel you'll ever need.

Readme

@smartimpact-it/modern-slick-carousel

A native-DOM TypeScript port of Slick. The goal is to preserve the commonly used options, methods, events, CSS classes and visual behavior of Slick 1.8.1 while removing its runtime jQuery dependency and incorporating relevant fixes from Slick 2.0.1.

This is a migration target, not a drop-in replacement for the original jQuery plugin. The native API below is the supported integration surface. Use the getters and documented methods to inspect and control an instance.

Documentation

The repository's docs/ folder contains a documentation site with live demos and the full settings, events and methods reference. Run npm run docs:build, then npm run docs:serve and open http://127.0.0.1:4174/.

Install

npm install @smartimpact-it/modern-slick-carousel

The package publishes ES2022 modules and TypeScript declarations. The minimum browser versions are Chrome 88, Firefox 90 and Safari 15.4. The optional jQuery bridge uses a separately supplied jQuery.

| Runtime feature | Chrome | Firefox | Safari | | --- | --- | --- | --- | | Element.replaceChildren() | 86 | 78 | 14 | | Native private class fields and methods | 84 | 90 | 15 | | AbortSignal in addEventListener() | 88 | 86 | 15.4 |

| Entry point | Purpose | | --- | --- | | @smartimpact-it/modern-slick-carousel | Native carousel with image lazy-loading. | | @smartimpact-it/modern-slick-carousel/element | <slick-carousel> custom element. Loads the carousel code when the first element starts. | | @smartimpact-it/modern-slick-carousel/jquery | Optional transitional jQuery plugin bridge. |

Import slick.css for layout and optionally slick-theme.css for the default arrow and dot presentation. The package ships the CSS, not the upstream SCSS/LESS sources. Supply your own theme styles if needed.

The stylesheets are also exported at the legacy slick/slick.css and slick/slick-theme.css paths. The theme uses CSS custom properties (--slick-arrow-color, --slick-dot-color, --slick-dot-character, --slick-dot-character-active, …) instead of the icon font and loader image.

Renamed package. Versions 2.0.0–2.0.2 were published as @smartimpact-it/modern-slick. From 3.0.0 the package is @smartimpact-it/modern-slick-carousel; update the dependency and every import specifier. See CHANGELOG.md for the breaking changes.

Native usage

<div class="js-carousel">
  <div>First slide</div>
  <div>Second slide</div>
  <div>Third slide</div>
  <div>Fourth slide</div>
</div>
import Slick from "@smartimpact-it/modern-slick-carousel";
import "@smartimpact-it/modern-slick-carousel/slick.css";
import "@smartimpact-it/modern-slick-carousel/slick-theme.css";

Slick.init(".js-carousel", { slidesToShow: 3 });

Slick.init(element, options?) returns one instance. A selector, array-like collection or iterable returns an array of instances. The list is snapshotted before initialization, so you can pass live collections. A selector with no matches returns []. An invalid selector throws.

Slick.getOrCreateInstance(target, options?) resolves one root and reuses an instance of the same class. Options apply only on creation. A missing root or an instance of a different Slick class throws.

new Slick(root, options?) initializes synchronously and throws for a missing or already initialized root. The constructor, getOrCreateInstance() and getInstance() use the first match when given a selector. getInstance() returns undefined when there is no live instance on that root.

const root = document.querySelector(".js-carousel");
Slick.getInstance(root)?.next();

Options are merged in this order: defaults, constructor settings, and then the root's optional JSON data-slick attribute (highest priority). Functions and element references must be supplied in JavaScript. Malformed JSON is ignored; supply valid option values.

Pass signal to tie the instance to an AbortController. Aborting destroys the carousel. A signal already aborted at construction returns a destroyed instance without changing the DOM or dispatching initialization events. Pass on and signal in the JavaScript creation options. Both are ignored in data-slick and responsive settings, and getOption() returns undefined for both.

Lifecycle

  • Create the instance when the root is connected. By default, Slick observes the root's content width and lays out when a hidden carousel becomes visible.
  • Root, window resize and orientation notifications share one animation-frame scheduler. Slick checks responsive breakpoints before sizing the track. Container notifications at the last layout width are ignored until the root is hidden or changes width.
  • With observeResize: false, or in a browser without ResizeObserver, call setPosition() after showing a hidden carousel or changing its container size independently of the window.
  • Call destroy() before discarding or replacing the carousel.
  • A responsive setting of "unslick" destroys the instance, as in Slick 1.8.1. Do not reuse a destroyed instance; create a new one. Set reslick: true to suspend it instead and build it again when the breakpoint no longer matches (see Reversible unslick).
  • Use native component lifecycle callbacks (for example, a custom element's connectedCallback and disconnectedCallback) to manage the instance and application-owned listeners.
  • element returns the root; slides returns a read-only array snapshot of the currently managed original slide elements (excluding loop clones). Do not mutate the internal $slider, $slides, $list, $slideTrack or other legacy collection fields.

Reversible unslick

With reslick: true, an "unslick" breakpoint suspends the carousel instead of destroying it. The instance stays registered, keeps its subscriptions and keeps watching its breakpoints. Leaving the breakpoint builds it again at the slide it showed before.

Slick.init(".product-grid", {
  slidesToShow: 4,
  reslick: true,
  responsive: [{ breakpoint: 768, settings: "unslick" }],
});

| | Active | Suspended | Destroyed | | --- | --- | --- | --- | | DOM | Built | Restored, as after destroy() | Restored | | Slick.getInstance(root) | The instance | The same instance | undefined | | destroyed / suspended | false / false | false / true | true / false | | on handlers and slick.on() subscriptions | Kept | Kept | Removed after destroy | | Build listeners, autoplay timer, pauseOnOutOfView observer | Live | Released | Released | | Breakpoint watching: window resize and orientation, and the root's size for respondTo: "slider" or "min" | Live | Kept | Released | | Aborting signal | Destroys | Destroys | No effect |

  • Entering an "unslick" breakpoint fires unslick with the breakpoint, and no destroy.
  • Leaving it builds the carousel with the new breakpoint's options, restores the remembered slide (clamped to the new range), then fires reInit and breakpoint.
  • If the first matching breakpoint is "unslick", the instance starts suspended: the DOM is untouched and no event fires. Check suspended for the initial state. The first build fires init; later builds fire reInit.
  • While suspended:
    • next(), prev(), goTo(), addSlide(), removeSlide(), filterSlides(), unfilterSlides(), setPosition() and refresh() do nothing and return the instance. Change the root's children directly; the next build uses them, with any filter applied again.
    • play() and pause() set the autoplay state for the next build. No timer runs.
    • setOption() stores the change. If the active breakpoint no longer resolves to "unslick", it builds the carousel immediately.
    • getOption() returns the base options.
    • currentSlide is the slide the carousel resumes at, moved if needed to a slide the new slidesToScroll can reach. A linked asNavFor carousel keeps it in step. A carousel that was never built starts like a new one: at initialSlide, or at its linked carousel's slide when initialSlide isn't set.
    • slides and slideCount describe the root's slide elements, before any filter. scrollable is false.
  • destroy() is final in every state. From the suspended state it leaves the DOM as it is and fires destroy.
  • reslick belongs to the instance and is ignored inside responsive settings. Set it in the creation options, in data-slick or with setOption(). Slick reads it whenever an "unslick" breakpoint is entered.
  • With respondTo: "slider" or "min", the root's size right after Slick builds or suspends counts as already measured. A root whose width depends on its content therefore can't keep switching between the two states.

Custom element

The ./element entry provides <slick-carousel>, which runs a carousel on its own children for as long as it's connected. Register it once:

import { defineSlickElement } from "@smartimpact-it/modern-slick-carousel/element";
import "@smartimpact-it/modern-slick-carousel/slick.css";

defineSlickElement();
<slick-carousel
  loading="lazy"
  options='{"slidesToShow": 4, "responsive": [{"breakpoint": 768, "settings": "unslick"}]}'
>
  <div>First slide</div>
  <div>Second slide</div>
</slick-carousel>
  • Options. The options attribute takes JSON. The options property takes an object, including on, signal and callbacks such as customPaging, and overrides the attribute key by key. The element's data-slick still applies on top, as on any Slick root. Changing the attribute or the property rebuilds a running carousel.
  • reslick defaults to true on the element, so an "unslick" breakpoint suspends the carousel and leaving it builds it again. Pass "reslick": false for a one-way unslick.
  • Start. The carousel starts once the parser has finished the element's children. With loading="lazy", it waits until the element comes within lazy-margin of the viewport (default 500px 0px). activate() starts it at once. A starting carousel also activates the <slick-carousel> elements named in its asNavFor, so a lazy thumbnail strip follows its gallery.
  • Registering before the page is parsed. Browsers don't report when an element's children are complete. While the page is still loading, the element treats its children as complete once it, or one of its ancestors, has a following node. A script that adds a node after an ancestor while the carousel's children are still arriving can make it start too early. Register from a module or defer script, which runs after parsing, to avoid this.
  • Failures. If the carousel can't start, for example because of an invalid option, the element logs the error. activate(), new options or reconnecting try again. Browsers usually remember a failed download of the carousel code, so that case needs a page reload.
  • Instance. slick returns the instance once created. ready resolves with it, and activate() returns the same promise. Slick.getInstance(element) returns the same instance. Listen for slick:* events on the element.
  • Removal. Removing the element destroys the carousel and restores its children. Moving it within one task keeps the carousel. When it's connected again, it builds a new carousel, and ready resolves with that one.
  • Inside another carousel. In an infinite carousel, loop clones of a built <slick-carousel> are static copies, without their own instance.
  • Loading. The entry is about 1.7 KB gzipped. It imports the carousel code the first time an element starts, so a page whose carousels are all lazy and below the fold loads Slick only when the first one approaches. Import the package root as well to load it with the page, for example for a carousel above the fold. Both share one copy of the code and one instance registry.
  • Names. defineSlickElement(name) registers another name with its own class, and returns the class already registered under that name. It returns undefined where there's no custom element registry, for example during server rendering. Subclass SlickCarouselElement to build your own element; call super from the lifecycle callbacks you override. Of its observed attributes, only options rebuilds the carousel.
  • Styles. slick.css gives slick-carousel display: block. Give an element registered under another name the same rule.

Options

All options are optional. The base options combine Slick.defaults, constructor settings, the root's data-slick JSON, and subsequent setOption() changes, in that order. Each merge is shallow and copies own enumerable keys. It ignores undefined, __proto__, constructor, and prototype.

The active breakpoint overrides the base. getOption() returns the effective value, including adjustments such as slidesToScroll: 1 in center mode. setOption() and play() update the base even while a breakpoint is active. For example, if the active breakpoint sets slidesToShow: 2 and you call setOption("slidesToShow", 3), the effective value remains 2 until you leave that breakpoint. Setting responsive replaces the entire breakpoint list.

setOption(key, value) and setOption(partial) apply changes immediately. The live options are autoplay, autoplaySpeed, speed, cssEase, easing, pauseOnHover, pauseOnFocus, pauseOnDotsHover, swipe, draggable, touchMove, touchThreshold, edgeFriction, waitForAnimate, focusOnChange, focusOnSelect, respectReducedMotion, zIndex and reslick. Changing effective autoplay enables or disables automatic navigation. A manual pause() remains in effect until play(). Any other option rebuilds the carousel. A single object call causes at most one rebuild. On a live instance, passing on or signal to setOption() throws a TypeError. Supply them at creation.

| Option | Default | Description | | --- | --- | --- | | slidesToShow | 1 | Number of slides visible. | | slidesToScroll | 1 | Number of slides advanced per navigation. Center mode and swipe-to-slide force this to one. | | initialSlide | 0 | Zero-based initial slide index. An explicit value overrides linked-carousel alignment. | | infinite | true | Loop by creating slide clones when needed. | | centerMode | false | Center the active slide. | | centerPadding | "50px" | Padding used by center mode. | | variableWidth | false | Use slide widths from the DOM rather than uniform widths. | | adaptiveHeight | false | Adjust list height to the current slide in single-slide horizontal mode. | | vertical | false | Vertical layout. | | verticalSwiping | false | Use vertical swipe gestures. | | rtl | false | Right-to-left layout and navigation. | | rows | 1 | Number of rows in grid mode. Set to zero to keep the original slides as track children without grid wrappers. | | slidesPerRow | 1 | Slides per row in grid mode. | | slide | "" | Selector restricting which direct children become slides. | | responsive | null | Array of breakpoint/settings pairs; settings may be partial options or "unslick". | | reslick | false | Suspend at an "unslick" breakpoint instead of destroying, and build again when it no longer matches. See Reversible unslick. | | mobileFirst | false | Apply breakpoints above the threshold instead of below it. | | respondTo | "window" | Breakpoint width source. With resize observation, "slider" and "min" also respond to container-only width changes. | | observeResize | true | Observe root content-width changes, including when a hidden root becomes visible. | | asNavFor | null | Link navigation to another carousel or a set of carousels. | | arrows | true | Enable previous/next arrows. | | prevArrow, nextArrow | Previous/Next buttons | Existing element, CSS selector or trusted HTML. | | appendArrows | Slider root | Container element or selector for generated arrows. | | dots | false | Enable pagination dots. | | dotsClass | "slick-dots" | Dot-list CSS class. | | appendDots | Slider root | Container element or selector for pagination. | | customPaging | Numbered button | Callback (slick, dotIndex) => content. Prefer returning a new native button element for accessible pagination. | | accessibility | true | Enable Slick's keyboard handling and ARIA updates. | | focusOnSelect | false | Select a slide on click. | | focusOnChange | false | Focus the current slide without scrolling. Autoplay moves focus only when it is already inside the carousel. | | autoplay | false | Enable automatic navigation. | | autoplaySpeed | 3000 | Autoplay interval in milliseconds. | | pauseOnHover, pauseOnFocus | true | Pause autoplay on hover or focus. | | pauseOnDotsHover | false | Pause autoplay while hovering pagination. | | pauseOnOutOfView | false | Accepts a boolean or a minimum visible fraction from 0 to 1. When enabled, pauses autoplay below that fraction, offscreen, or while the document is hidden. | | draggable | true | Enable mouse dragging. | | swipe | true | Enable mouse, touch and pen swipe gestures. | | swipeToSlide | false | Select the destination using the swipe distance. | | touchMove | true | Enable touch and pen gestures and move the track during a drag. | | touchThreshold | 5 | Swipe threshold divisor. | | edgeFriction | 0.35 | Resistance at non-infinite edges. | | fade | false | Use opacity transitions rather than slide movement. | | speed | 500 | Animation duration in milliseconds. | | respectReducedMotion | true | Complete slide, fade and adaptive-height animations immediately when the system requests reduced motion. | | cssEase | "ease" | CSS transition easing. | | easing | "linear" | JavaScript easing: "linear" or "swing". Unknown names fall back to linear. | | useCSS | true | Use CSS transitions for transform/fade animations; false uses native JavaScript. | | useTransform | true | Use transforms for track movement; false animates left/top. | | waitForAnimate | true | Ignore navigation while an animation is in progress. | | zIndex | 1000 | Fade-slide stacking order. | | lazyLoad | "ondemand" | "ondemand", "anticipated" or "progressive". | | onClone | Not set | Native clone initialization callback; may return a cleanup function. |

In center mode, when all slides fit, fixed-width horizontal slides divide the list's content width evenly and vertical lists size to the actual slide count. The configured slidesToShow stays in effect as slides are added or removed.

On initialization, asNavFor copies the current index from the first live linked carousel and clamps it to the new carousel's range. An explicit initialSlide in the JavaScript settings, data-slick, or the active breakpoint takes precedence. Carousels can initialize in either order because targets are also resolved when navigation occurs.

With pauseOnOutOfView: 0.5, at least half the root must be visible for autoplay. Numeric values are clamped to [0, 1]. Both true and 0 allow autoplay as soon as the root intersects the viewport. Changing the effective setting with setOption() rebuilds the carousel and updates its observer. Returning to view preserves manual, hover, focus and swipe pauses. Page visibility still applies if the browser lacks IntersectionObserver.

Markup options and slide insertion strings must be trusted HTML. Prefer native elements for dynamically generated controls.

Animation behavior

With useCSS: false, movement, fade and adaptive-height animations use requestAnimationFrame. JavaScript left/top movement (also used with useTransform: false), height and opacity animations run in order on each element. JavaScript transform animations run independently, as in Slick 1.8.1. With waitForAnimate: false, a new CSS transition takes precedence over an earlier one. Zero speed is immediate when no animation is queued. Third-party jQuery easing plugins are not supported.

Clones

Infinite mode creates additional DOM elements for the loop. IDs are stripped from clones, and clones do not share application state or arbitrary native event listeners with their originals. Use delegated listeners on the root where possible. Resolve a rendered slide to its original with slick.getOriginalSlide(slide); the argument is the slide element, not an arbitrary descendant. With grid mode enabled, that element may be a generated grid slide.

For explicit initialization, supply the optional callback:

const slick = new Slick(element, {
  rows: 0,
  onClone(clone, original, instance) {
    const observer = new ResizeObserver(() => {
      // Update clone-specific behavior.
    });
    observer.observe(clone);
    // Optional: called before Slick removes this clone during rebuild/destroy.
    return () => observer.disconnect();
  },
});

Do not assume a cloned form or a cloned custom element is equivalent to the original instance. Use the component's own lifecycle where possible, validate form associations and delegated actions, and avoid infinite mode if a component cannot safely be duplicated.

Legacy image lazy-loading

Image lazy-loading is part of the main entry. Replace imports from the removed ./full entry with imports from the package root. Use data-lazy and the optional data-srcset and data-sizes attributes to supply image sources.

import Slick from "@smartimpact-it/modern-slick-carousel";

const slick = new Slick(element, {
  rows: 0,
  lazyLoad: "anticipated",
});

Native lazy-load events include the image element.

Methods and properties

| Instance API | Description | | --- | --- | | next(), prev() | Navigate one step forward or backward. | | goTo(target, dontAnimate?) | Navigate to a numeric index or the slide containing an element. Pass true to skip animation. | | play(), pause() | Start or pause autoplay. | | addSlide(content, index?, addBefore?) | Insert a node, an array-like collection of nodes or trusted HTML markup. With no index, append by default. A boolean second argument selects prepend (true) or append (false). | | removeSlide(index, removeBefore?, removeAll?) | Remove a slide. A boolean first argument selects the first (true) or last (false) slide. removeAll removes all slides. | | filterSlides(filter), unfilterSlides() | Filter by selector, element collection or predicate (index, element) => boolean, or restore the filtered slides. | | setOption(key, value), setOption(partial) | Apply one or more options. | | setPosition() | Recalculate layout and position. | | refresh() | Rebuild with the current options. | | destroy() | Tear down the carousel. Returns undefined. | | getOption(key) | Read a typed effective option value. | | getOriginalSlide(slide) | Resolve a loop clone to its original slide. | | on(name, handler, options?), off(name?, handler?) | Subscribe to or remove instance event subscriptions. | | element | Root DOM element. | | slides | Read-only snapshot of original managed slides. While suspended, the root's slide elements. | | slideCount | Count of currently managed original slides. | | currentSlide | Current slide index. While suspended, the slide the carousel resumes at. | | animating | Whether a slide transition is active. | | paused | Read-only. true after a manual pause() or when effective autoplay is false. Hover (including dot hover), focus, swipe and pauseOnOutOfView leave it unchanged. | | scrollable | Read-only. true when the current build has more navigable slides than fit. false when all slides fit, or the instance is suspended or destroyed. | | suspended | Read-only. true while a reslick carousel is unbuilt inside an "unslick" breakpoint. | | destroyed | Whether the instance has been destroyed. |

Use scrollable to style carousels that fit or toggle custom controls. In a slick:setPosition listener, compare it with the previous value for that instance and update only when it changes. The getter uses the current slide count and effective slidesToShow without measuring the DOM.

Every action from next() through refresh() returns the instance. Calls on a destroyed instance and invalid inputs such as an out-of-range removal index are no-ops. On a live instance, a string passed to addSlide() must be trusted HTML markup. A selector or plain text throws a TypeError. The prevArrow and nextArrow options still accept CSS selectors as well as markup or elements.

play() clears a manual pause and enables base autoplay. paused then becomes false when effective autoplay is enabled. An active breakpoint can still disable autoplay.

Numeric goTo() follows the carousel's navigation steps. An element target selects the exact index of its closest managed slide, mapping a loop clone to its original. Elements from another carousel, including nested carousels, and filtered-out or detached elements are ignored. In a theme editor's block-select handler, pass the selected block directly.

Slick.getInstance(root)?.goTo(blockElement).pause();

Migrating from 3.x

  • Import the native class from the package root. The ./full entry was removed and image lazy-loading is in the core. The ./jquery entry shares that class.
  • The ES2022 bundles require Chrome 88, Firefox 90 or Safari 15.4 and later.
  • Use the native method names above on instances. Switch getSlick() to Slick.getInstance(root), getCurrent() and slickCurrentSlide() to currentSlide, and unslick() to destroy(). The unslick event remains available for responsive "unslick" and the bridge's unslick command. The jQuery command table covers the legacy aliases.
  • Use the public getters for instance state because internals are private. Rename unslicked to destroyed; use getOption() and setOption() for options. Call refresh() and destroy() without arguments.
  • Action methods return the instance, including addSlide() and removeSlide() when a call does nothing. Check slideCount or events if you need to observe a change. Pass nodes or trusted markup to addSlide(). Use document.querySelectorAll() before calling it if you have a selector.
  • Remove refresh flags from setOption(). Structural changes rebuild automatically. Configure on and signal at creation.
  • Listen to native DOM events as slick:<name>. They bubble without cancellation. Destructure the named fields in event.detail; 3.x's array payloads are gone. SlickEventMap describes the detail objects. The native unslick event from a manual bridge command carries a null breakpoint.
  • Pass a single short event name to slick.on(). The handler gets the detail object and runs with the instance as this. It receives only that carousel's events and is removed after destroy. Call the returned unsubscribe function or use off() to remove subscriptions. Native subscriptions no longer use namespaces, space-separated event names, or special handling for a handler returning false.
  • Call registerJQueryPlugin($) to install $.fn.slick. Importing the bridge has no registration side effect. It triggers legacy jQuery events directly without patching jQuery.event.special. Actions visit all initialized elements and return the collection, getters use the first initialized element, and unknown commands throw a TypeError.

Behavior changes

  • A filter stays applied across refreshes and breakpoint changes. Call unfilterSlides() to show all retained originals. destroy() restores them in order, including grid cells, with their original node identity.
  • If setup throws, the carousel restores the DOM and releases its instance registration so you can retry. Mutations requested by setup callbacks run in order after init. Calling destroy() during setup aborts it and drops queued mutations.
  • Slick restores adopted arrow and dot attributes when it replaces or releases those controls. Getters remain available after teardown.
  • Options follow the base and breakpoint precedence above. Autoplay creates an interval only when the effective autoplay is enabled. Manual pauses survive rebuilds and pauseOnOutOfView can add a viewport and page visibility pause.
  • asNavFor forwards accepted moves using the destination index. Earlier CSS completions leave the latest transition active. Completed moves emit afterChange in navigation order.
  • A new linked carousel starts at the partner's current slide unless it specifies its own initialSlide.
  • Resize observation is enabled by default. It handles container-only width changes and hidden-to-visible layouts, and rechecks "slider" and "min" breakpoints. Set observeResize: false for window-only resize handling.
  • Lazy loading reuses each image's in-flight or completed request across refreshes. Image events follow the current build.
  • Slide sizing uses fractional layout dimensions, so CSS transforms on the carousel or its ancestors do not change its measurements.
  • When a slide hides the focused element, focus moves without scrolling to the new current slide or to the list. The list's keyboard focus outline can be styled with --slick-focus-outline. Arrow keys work from that fallback and are ignored in editable controls or when a modifier key is held.
  • Pagination uses instance-scoped ARIA IDs, preserves authored slide IDs and keeps the tab and panel relationships current through rebuilds. Hidden slides and clones stay out of the tab order. Visible original slides recover their authored descendant tabindex values, and peeking slides remain clickable.
  • focusOnChange moves focus without scrolling. Autoplay can move focus only when it is already inside the carousel.
  • respectReducedMotion is enabled by default and checks the system preference at each animation. Slide movement, fades and adaptive height finish immediately when reduced motion is requested. Autoplay keeps its regular interval.
  • Dragging and swiping use Pointer Events with pointer capture. Mouse dragging requires draggable and swipe. Touch and pen require swipe and touchMove. The list allows native vertical page scrolling in horizontal layouts and horizontal scrolling in vertical layouts. It suppresses the click after a drag. Nested carousels handle their own drag, swipe and focusOnSelect interactions.

Events

Slick dispatches bubbling, non-cancelable slick:<name> events on the root. Every event carries a typed detail object. SlickEventMap maps short names to details, and SlickEvent<"afterChange"> types a full DOM event.

| Short name | detail | | --- | --- | | init, reInit, destroy, setPosition | { slick } | | unslick, breakpoint | { slick, breakpoint }, with breakpoint set to a number or null | | beforeChange | { slick, currentSlide, nextSlide } | | afterChange | { slick, currentSlide } | | swipe, edge | { slick, direction }, with "left", "right", "up" or "down" | | lazyLoaded, lazyLoadError | { slick, image, source }, with image typed as HTMLImageElement | | allImagesLoaded | { slick } in progressive lazy-load mode |

Use the on option to listen from the start of setup, including the first setPosition and synchronous init. This example takes an uninitialized root and an abort signal owned by the caller.

function mountCarousel(root: HTMLElement, signal: AbortSignal) {
  const slick = new Slick(root, {
    on: { afterChange: ({ currentSlide }) => {} },
    signal,
  });
  return slick;
}

On an existing instance, slick.on(name, handler, { once, signal }) returns an unsubscribe function. Both options are optional. The handler receives detail and runs with this set to the instance. Instance subscriptions receive only that instance's events, survive refreshes, and are removed after destroy is delivered. Use off(name, handler) to remove one registration, off(name) to remove all handlers for that name, or off() to remove all instance subscriptions.

const unsubscribe = slick.on("afterChange", ({ currentSlide }) => {
  console.log(currentSlide);
});
unsubscribe();

Use DOM listeners when you want bubbling, such as delegation across several carousels. Register before construction to catch synchronous setup events, including on carousels initialized later. TypeScript infers the event from its prefixed name on HTML elements, document and window.

root.addEventListener("slick:afterChange", (e) => e.detail.currentSlide);
document.addEventListener("slick:init", (e) => e.detail.slick);
window.addEventListener("slick:init", (e) => e.detail.slick);

Migrating from slick-carousel

Use Slick.init(root, options) to initialize, Slick.getInstance(root) to look up an instance, and destroy() to tear it down. Use the native method names and slick:* events. Slick retains its main CSS classes and list/track/slide structure. For integrations that still call $.fn.slick, register the optional bridge and use the command table below.

DOM integration

Infinite mode copies form controls with their name attributes intact. Checking a radio in a clone can uncheck an original radio of the same name in the same form. FormData includes every successful control, so original and cloned text inputs with the same name produce repeated entries. Clones also have their own custom element lifecycle. When Slick moves original slides into or out of a connected track, their custom elements can disconnect and reconnect.

Destroy restores the attributes Slick manages on the original slides and adopted controls, and removes generated controls. Attributes Slick added are removed when they were originally absent. Slide additions, removals and lazy-loaded image changes can persist after teardown. With a slide selector, other siblings can shift relative to the managed slides when the track is unwrapped. Grid teardown restores the order of the managed slide elements. Whitespace and other non-element children can be lost when grid wrappers are built. As in Slick 1.8.1, a slide mutation during navigation can leave a queued completion for the pre-mutation slide index.

Clone initialization uses native DOM lifecycle callbacks, event delegation, or onClone. jQuery data/events and third-party jQuery plugin state require application-managed initialization.

Optional transitional jQuery bridge

Use only if an existing integration still needs the plugin surface. New native integrations do not need jQuery.

import $ from "jquery";
import { registerJQueryPlugin } from "@smartimpact-it/modern-slick-carousel/jquery";

registerJQueryPlugin($);
$(".carousel").slick({ slidesToShow: 2 });

The bridge requires explicit registration. An existing $.fn.slick is preserved by default. For a lazy-loader placeholder, explicitly use registerJQueryPlugin($, { replaceExisting: true }) before marking the module loaded. Never use that option to replace a live upstream carousel. The bridge triggers the legacy short event names with their positional arguments, including jQuery collections for lazy-load images. jQuery namespaces such as afterChange.gallery work as usual.

jQuery commands

$(selector).slick(options?) reuses or creates an instance on every matched element and returns the collection. All action commands apply to every initialized match and return the collection. Getters return the first initialized match's value, or undefined if none exists. The bridge also accepts the native names in the second column wherever one is shown.

| Legacy command | Native equivalent | Behavior | | --- | --- | --- | | slickNext | next | Action | | slickPrev | prev | Action | | slickGoTo | goTo | Action | | slickPause | pause | Action | | slickPlay | play | Action | | slickAdd | addSlide | Action | | slickRemove | removeSlide | Action | | slickFilter | filterSlides | Action | | slickUnfilter | unfilterSlides | Action | | slickSetOption | setOption | Action. The legacy trailing refresh boolean is ignored. | | setPosition | setPosition | Action | | refresh | refresh | Action | | unslick | destroy | Action. The unslick command emits the unslick event before tearing down. | | slickGetOption | getOption | Getter | | slickCurrentSlide | currentSlide | Getter | | getSlick | | Getter for the instance |

Unknown commands throw a TypeError.

Development

npm ci
npm run typecheck
npm run build
npm run test:types
npm test
npx playwright install chromium firefox webkit
npm run test:playwright
npm run size

Type checking uses full strict mode. The build emits ES modules and declaration files. The smoke and demo tests exercise the built bundles; Playwright exercises real browser layout, animation and lifecycle behavior.

npm run size reports raw, gzip and Brotli bytes for each entry, including its shared chunks. In 4.0, slides and controls share attribute snapshot capture, and option handling shares the own-property checks.

For the interactive native playground, build the package, serve the project root (for example, npx serve .), and visit /demo/.

Build the documentation site with npm run docs:build and preview it with npm run docs:serve. npm run test:playwright builds it first and tests it.

License and upstream

MIT. Based on slick-carousel by Ken Wheeler and its contributors. See the upstream 1.8.1 source and 2.0.1 release for historical behavior and development context.