Swipe Scroller for Svelte
Horizontal card slider for the modern web. Requires minimum JavaScript. Demo
Features
- Snapping Cards, Smooth Scroll - Powered by CSS, not JS.
- Easy to Use - Just pass the card components to the
<slot />
. - Customizable - Override the provided buttons and
<noscript>
. - Various Controls - Supports touch, scroll, click1, and the
tab
key2. - Light or Dark - The semi-transparent clickable buttons suits both.
Requirements
Supported and tested on the latest evergreen browsers.
Limitations
- JavaScript is required to enable horizontal scroll.
- Card components should have identical width.
Installation
Reference How it works for in-depth explanation.
- Prepare a SvelteKit project3.
- Install the package via npm.
- Reference the src/routes directory4.
For new projects, replace the content of the src/routes
folder. Download
Events
Options
export let buttonWidth = '2.5rem';
export let cardGap = '1.25rem';
export let hangButtons = true;
export let invertButtons = false;
Slots
<!-- Optional Named Slots -->
<slot name="noscript" />
<slot name="button-prev" />
<slot name="button-next" />