The ultimate card carousel component for Svelte 4.
yarn add svelte-card-carousel
npm i svelte-card-carousel
pnpm i svelte-card-carousel
<script>
import Carousel from 'svelte-card-carousel';
...
</script>
<Carousel
data={data}
autoScroll={true}
autoScrollSpeed={3000}
dragAcceleration={1.5}
wrapLeft={true}
wrapRight={true}
/>
{
"cards": [
{
"imageSrc": "https://source.unsplash.com/featured/?landscape",
"videoSrc": "https://www.shutterstock.com/shutterstock/videos/1052743418/preview/stock-footage--aerial-drone-distant-sunset-view-of-tour-eiffel-tower-and-seine-river-bridge-traffic-cars-driving.webm",
"title": "Stunning Random, Landscape",
"label": "Nature",
"paragraph": "This is a beautiful landscape. The rolling hills stretch out as far as the eye can see. The sky above is a brilliant blue, dotted with fluffy clouds.",
"buttonText": "Learn More",
"buttonLink": "https://google.ca/"
}
]
}
If you're using SvelteKit, follow these additional steps:
pnpm i svelte-card-carousel -D
kit
in svelte.config.js
to include the vite
property.const config = {
kit: {
vite: {
optimizeDeps: {
include: ['svelte-card-carousel']
}
}
}
}
Prop | Type | Default | Description |
---|---|---|---|
data |
array |
[] |
An array of card data objects. |
autoScroll |
boolean |
false |
Enable/disable auto-scrolling. |
autoScrollSpeed |
number |
3000 |
Speed of auto-scrolling in ms. |
dragAcceleration |
number |
1.5 |
Acceleration factor for drag. |
wrapLeft |
boolean |
true |
Enable/disable wrap to last item. |
wrapRight |
boolean |
true |
Enable/disable wrap to first item. |
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT