svelte-flex-slider
v1.0.5
Published
A flexible and responsive slider/carousel component for Svelte applications
Downloads
20
Maintainers
Readme
Svelte Flex Slider
A flexible and responsive slider component for Svelte applications.
Features
- Responsive design with customizable breakpoints
- Autoplay functionality with adjustable interval
- Loop option for continuous sliding
- Touch-friendly navigation
- Customizable number of visible cards
- Optional navigation buttons and indicators
- Easy to integrate and style
Installation
Install Svelte Flex Slider with npm:
npm install svelte-flex-slider
Usage
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}
/>
Documentation
For full documentation and interactive examples, visit our documentation site.
API
| 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. |
Examples
Image Slider with Custom Navigation
<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}
/>
Product Showcase with Indicators
<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.
Styling
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.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
Support
If you encounter any problems or have any questions, please open an issue on the GitHub repository.
Acknowledgements
- Thanks to the Svelte community for their amazing tools and support.
- Icons provided by Lucide.
Made with ❤️ by Naresh Choudhary (nakxa)