A flexible and responsive slider component for Svelte applications.
Install Svelte Flex Slider with npm:
npm install svelte-flex-slider
Import and use the SvelteFlexSlider component in your Svelte file:
<script>
import SvelteFlexSlider from 'svelte-flex-slider';
const cards = [
'<div>Slide 1</div>',
'<div>Slide 2</div>',
'<div>Slide 3</div>'
];
</script>
<SvelteFlexSlider
{cards}
autoplay={true}
interval={3000}
loop={true}
visibleCards={{ default: 1, 768: 2, 1024: 3 }}
showNavButtons={true}
showIndicators={true}
/>
For full documentation and interactive examples, visit our documentation site.
Prop | Type | Default | Description |
---|---|---|---|
cards | array | [] | Array of card contents to be displayed in the slider. |
autoplay | boolean | true | Whether the slider should autoplay. |
interval | number | 3000 | Interval between slides in milliseconds when autoplay is enabled. |
loop | boolean | true | Whether the slider should loop back to the beginning after reaching the end. |
visibleCards | object | { default: 1 } | Number of visible cards at different breakpoints. |
showNavButtons | boolean | true | Whether to show navigation buttons. |
showIndicators | boolean | true | Whether to show slide indicators. |
<SvelteFlexSlider
cards={[
'<div><img src="img1.jpg" alt="Slide 1"></div>',
'<div><img src="img2.jpg" alt="Slide 2"></div>',
'<div><img src="img3.jpg" alt="Slide 3"></div>'
]}
autoplay={true}
interval={3000}
loop={true}
visibleCards={{ default: 1 }}
showNavButtons={true}
showIndicators={false}
/>
<SvelteFlexSlider
cards={[
'<div class="product"><img src="product1.jpg" alt="Product 1"><h3>Product 1</h3><p>$19.99</p></div>',
'<div class="product"><img src="product2.jpg" alt="Product 2"><h3>Product 2</h3><p>$24.99</p></div>',
'<div class="product"><img src="product3.jpg" alt="Product 3"><h3>Product 3</h3><p>$29.99</p></div>'
]}
autoplay={false}
interval={3000}
loop={true}
visibleCards={{ default: 1, 520: 2, 800: 3 }}
showNavButtons={false}
showIndicators={true}
/>
For more examples and interactive demos, visit our documentation site.
Svelte Flex Slider comes with minimal default styling. You can easily customize the appearance by adding your own CSS classes or inline styles to the card contents.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
If you encounter any problems or have any questions, please open an issue on the GitHub repository.
Made with ❤️ by Naresh Choudhary (nakxa)