Unlock the full potential of PixieSlider now!

PixieSlider API Reference
A complete reference for all configuration options, methods, static properties, and module features for PixieSlider and its modules.
Initialization
Create a new slider by passing the container ID or element and an optional configuration object.
import { PixieSlider } from 'pixie-slider';

new PixieSlider('slider-id', {
    autoPlay: true,
    lazyLoad: true,
    captions: true,
    // ...other options
});
Static Properties
Property Type Default Description
ALLOW_UNSAFE_HTMLbooleanfalseIf true, allows raw HTML in slide.html. Warning: This is dangerous! Only enable if you sanitize input yourself.
ENABLE_PERF_LOGGINGbooleanfalseIf true, logs slide load times and frame rates for performance analysis.
Configuration Options
All options are optional unless otherwise noted. Module-specific options are listed below.
Option Type Default Description
slidesSlide[][]Array of slide objects. If empty, slides are read from DOM.
autoPlaybooleantrueEnable automatic slide transitions.
autoPlaySpeednumber4000Autoplay interval in ms.
pauseOnHoverbooleanfalsePause autoplay on mouse hover.
transition'slide' | 'fade''slide'Transition effect between slides.
transitionDurationnumber700Transition duration in ms.
easingstring'ease-in-out'CSS easing for transitions.
spacingnumber0Space (px) between slides.
paginationDotsbooleanfalseShow pagination dots below the slider.
fullscreenbooleanfalseEnable fullscreen button.
progressBarbooleanfalseShow a progress bar for autoplay.
lazyLoadbooleanfalseEnable lazy loading for images/videos.
videoAwarenessbooleanfalsePause autoplay when video is playing.
touchSupportbooleanfalseEnable swipe gestures on touch devices.
lazyThresholdnumber2How many slides ahead/behind to preload (lazy loading).
onSlideChange(index: number) => void-Callback when the slide changes.
thumbnailsbooleanfalseShow thumbnail navigation.
thumbnailSizenumber60Size of thumbnails in px.
thumbnailVerticalbooleanfalseDisplay thumbnails vertically.
captionsbooleanfalseEnable animated captions for slides.
captionAnimations'fade' | 'slide' | 'zoom''fade'Default animation for captions.
captionPositionstring'bottom-center'Default position for captions.
startIndexnumber0Index of the initial slide.
navigationbooleantrueShow next/prev navigation arrows.
navPrevTemplatestring'‹'HTML for previous arrow button.
navNextTemplatestring'›'HTML for next arrow button.
navPrevClassstring(see source)CSS classes for previous arrow.
navNextClassstring(see source)CSS classes for next arrow.
navAutoHidebooleanfalseAuto-hide navigation arrows after inactivity.
navAutoHideDelaynumber2000Delay (ms) before auto-hiding navigation arrows.
paginationWrapperClassstring(see source)CSS classes for pagination wrapper.
paginationDotClassstring(see source)CSS classes for pagination dots.
paginationActiveDotClassstring(see source)CSS classes for active pagination dot.
paginationDirection'horizontal' | 'vertical''horizontal'Direction of pagination dots.
paginationTransitionClassstring(see source)CSS classes for pagination transitions.
progressBarColorstring'#000'Color of the progress bar.
touchThresholdnumber50Minimum swipe distance to trigger slide change.
touchVerticalTolerancenumber80Vertical movement allowed before canceling swipe.
lazyRootMarginstring'50px'Root margin for lazy loading (IntersectionObserver).
lazyUnloadbooleanfalseUnload media when out of view (lazy loading).
Methods
Call these methods on your PixieSlider instance.
  • goToSlide(index: number) — Go to a specific slide.
  • nextSlide() — Advance to the next slide.
  • prevSlide() — Go to the previous slide.
  • pause() — Pause autoplay.
  • resume() — Resume autoplay.
  • destroy() — Destroy the slider and clean up resources.
  • getCurrentSlide() — Get the current slide object.
  • getTotalSlides() — Get the total number of slides.
const slider = new PixieSlider('slider-id');
slider.goToSlide(2);
slider.pause();
slider.resume();
slider.destroy();
Slide Markup & Data Attributes
Each slide is a
with data-slide and media attributes:
<div data-slide data-media="image.jpg" data-media-alt="Description" data-media-type="image|video" data-captions='{...}' data-duration="4000"></div>
  • data-media: Image or video URL.
  • data-media-type: 'image' or 'video'.
  • data-media-alt: Alt text for accessibility.
  • data-captions: JSON string for captions (see below).
  • data-duration: Per-slide duration (ms).
  • data-html: Custom HTML for the slide (see ALLOW_UNSAFE_HTML).
Captions API
Add animated, styled captions to any slide using data-captions:
<div data-slide data-media="image.jpg" data-captions='[
  { "text": "Hello World!", "position": "top-center", "animation": "fade", "delay": 500, "duration": 1000, "className": "text-2xl font-bold" }
]'></div>
  • text: Caption text.
  • position: 'top-left', 'top-center', 'bottom-right', etc.
  • animation: 'fade', 'slide-left', 'slide-right', 'slide-top', 'slide-bottom', 'zoom'.
  • delay: Animation delay (ms).
  • duration: Animation duration (ms).
  • className: Extra CSS classes (e.g., Tailwind).
  • responsive: true/false for responsive text.
Events & Callbacks
Use these callbacks for integration:
  • onSlideChange(index: number): Called when the slide changes.
new PixieSlider('slider-id', {
  onSlideChange: (index) => {
    console.log('Slide changed to', index);
  }
})
Module Features & Advanced Options
  • Autoplay: Automatic slide transitions, pause/resume, per-slide duration.
  • Lazy Loading: Loads images/videos as they approach the viewport for performance. Options: lazyRootMargin, lazyUnload, lazyThreshold.
  • Captions: Animated, styled, multi-text captions with full Tailwind support. Options: captionAnimations, captionPosition.
  • Fullscreen: Toggle fullscreen mode for immersive viewing.
  • Thumbnails: Clickable thumbnail navigation. Options: thumbnailSize, thumbnailVertical.
  • Progress Bar: Visual progress indicator for autoplay. Option: progressBarColor.
  • Touch Support: Swipe gestures for mobile devices. Options: touchThreshold, touchVerticalTolerance.
  • Navigation: Next/prev arrows. Options: navPrevTemplate, navNextTemplate, navPrevClass, navNextClass, navAutoHide, navAutoHideDelay.
  • Pagination: Dots navigation. Options: paginationWrapperClass, paginationDotClass, paginationActiveDotClass, paginationDirection, paginationTransitionClass.
  • Video Awareness: Pauses autoplay when video is playing.
For more advanced usage and live examples, see the Examples page.