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 🙏

© 2024 – Pkg Stats / Ryan Hefner

alpine-splide

v1.2.0

Published

The Alpine component for Splide.

Downloads

2,241

Readme

Alpine Splide

The Alpine component for the Splide slider/carousel.

Splide JS | Demo | Alpine JS


Installation

There are three recommended methods of loading Alpine Splide. Adding a script tag with a CDN, importing it into your bundle with npm, importing with script type="module", or adding a script tag with a CDN. You could also download src/js/components/Splide.js and include it directly into your project.

Which method you use will depend on how you prefer to use and import Alpine.js.

Make sure to also include Splide CSS via your preferred method.

CDN (easy)

If you load Alpine from a CDN like jsdelivr or unpkg with a script tag you can load Alpine Splide via the same method:

<script src="https://unpkg.com/[email protected]/dist/js/alpine-splide.script.js"></script>
<script src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>

When loading via this method you need to make sure that Alpine Splide loads first. This is generally done by including the script tag for Alpine Splide before Alpine. Watch out for using type="module" or async.

See usage for markup and usage information.

npm

Install from npm with:

npm install alpine-splide

Import it into your bundle alongside Alpine and register it with Alpine.data():

import Alpine from 'alpinejs'
import Splide from 'alpine-splide'

Alpine.data('Splide', Splide)

Alpine.start()

Module Script

You can use skypack to import using ES Modules similar to above like so:

import Alpine from 'https://cdn.skypack.dev/alpinejs';
import Splide from 'https://cdn.skypack.dev/alpine-splide'

Alpine.data('Splide', Splide)

Alpine.start()

Usage

Basic usage:

<div class="splide" x-data="Splide">
  <div class="splide__track">
    <ul class="splide__list">
      <li>...</li>
      <li>...</li>
      <li>...</li>
    </ul>
  </div>
</div>

Providing options to splide and using the buildMarkup option to simplify source markup:

<div x-data="Splide({
  buildMarkup: true,
  options: {
    type: 'loop',
    perPage: 3
  }
})">
  <li>...</li>
  <li>...</li>
  <li>...</li>
</div>

Advanced

For advanced usage you can declare x-data="Splide" further up the DOM tree from the actual slider element by adding x-ref="slider" on the slider element.

The suggested method of extending Alpine Splide is by copying the source and modifying it to your requirements. You can however also destructure the Splide component into a different x-data object, call splideInit() manually and work with this.splide:

<div x-data="{
  ...Splide(),
  init() {
    this.splideInit()
    console.log(this.splide)
  }
}">

Options

options

Splide options provided as an object:

<div x-data="Splide({
  options: {
    type: 'loop',
    perPage: 5
  }
})"></div>

buildMarkup

Allows you to skip building Splide DOM structure (splide__track, splide__list) and it will instead be built for you. Default false.

Simply provide slides as elements directly within the x-data="Splide" element.

License and Credits

Alpine Splide and Splide are released under the MIT license. Splide code and trademarks remain with the original author Naotoshi Fujita.

Alpine Splide - © 2021 Alistair Shepherd

Splide - © 2021 Naotoshi Fujita