The Alpine component for Splide.
npm install alpine-splideThe Alpine component for the Splide slider/carousel.
*
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.
If you load Alpine from a CDN like jsdelivr or unpkg with a script tag you can load Alpine Splide via the same method:
``html`
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.
Install from npm with:
``
npm install alpine-splide
Import it into your bundle alongside Alpine and register it with Alpine.data():`js
import Alpine from 'alpinejs'
import Splide from 'alpine-splide'
Alpine.data('Splide', Splide)
Alpine.start()
`
You can use skypack to import using ES Modules similar to above like so:
`js
import Alpine from 'https://cdn.skypack.dev/alpinejs';
import Splide from 'https://cdn.skypack.dev/alpine-splide'
Alpine.data('Splide', Splide)
Alpine.start()
`
*
Basic usage:
`html`
Providing options to splide and using the buildMarkup option to simplify source markup:`html`
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:
` Splide options provided as an object: Allows you to skip building Splide DOM structure ( Simply provide slides as elements directly within the 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 Fujitahtml
``Options
$3
html`splide__track$3
, splide__list) and it will instead be built for you. Default false.x-data="Splide"` element.License and Credits