Svelte Splide is the Splide component for Svelte
Svelte Splide is the Splide component for Svelte
npm install svelte-splide
<link rel="stylesheet" href="node_modules/@splidejs/splide/dist/css/splide.min.css">
import "@splidejs/splide/dist/css/splide.min.css";
<script>
import { Splide, SplideSlide } from "svelte-splide";
</script>
<Splide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
options
prop:<script>
import { Splide, SplideSlide } from "svelte-splide";
const options = {
arrows: true,
pagination: false,
autoWidth: true,
rewind: false,
gap: 50
};
</script>
<Splide {options}>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
<script>
import { Splide, SplideSlide } from "svelte-splide";
let extensions = {};
let transition = null;
</script>
<Splide {extensions} {transition}>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
splide
prop:<script>
import { Splide, SplideSlide } from "svelte-splide";
let splide;
</script>
<Splide bind:splide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
<script>
import { Splide, SplideSlide } from "svelte-splide";
let currentIndex;
</script>
<p>Current index: {currentIndex}</p>
<Splide bind:currentIndex>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
In addition to every base Splide feature, svelte-splide supports:
<script>
import { Splide, SplideSlide } from "svelte-splide";
</script>
<Splide autoHideArrows autoHideArrowsOffset={0}>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
<script>
import { Splide, SplideSlide } from "svelte-splide";
</script>
<Splide group="demo">
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
<br/>
<Splide group="demo">
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>
<br/>
<Splide group="demo">
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
<SplideSlide>
<img src="https://via.placeholder.com/540x360" alt="" />
</SplideSlide>
</Splide>