diff --git a/src/lib/carousels/Carousel.svelte b/src/lib/carousels/Carousel.svelte index 3518bcfc6..c29417b05 100644 --- a/src/lib/carousels/Carousel.svelte +++ b/src/lib/carousels/Carousel.svelte @@ -14,6 +14,7 @@ import { twMerge } from 'tailwind-merge'; import Controls from './Controls.svelte'; import Indicators from './Indicators.svelte'; + import Slide from './Slide.svelte'; type TransitionFunc = (node: HTMLElement, params: any) => TransitionConfig; @@ -21,8 +22,8 @@ export let index: number = 0; export let transition: TransitionFunc = (x) => fade(x, { duration: 700, easing: quintOut }); export let duration: number = 0; - export let ariaLabel: string = 'Draggable Carousel'; - + export let ariaLabel: string = 'Draggable Carousel'; + // Carousel let divClass: string = 'overflow-hidden relative rounded-lg h-56 sm:h-64 xl:h-80 2xl:h-96'; @@ -149,9 +150,9 @@
- {#key images[index]} - ... - {/key} + + +
diff --git a/src/lib/carousels/Slide.svelte b/src/lib/carousels/Slide.svelte new file mode 100644 index 000000000..e07784ed8 --- /dev/null +++ b/src/lib/carousels/Slide.svelte @@ -0,0 +1,14 @@ + + +{#key image} + ... +{/key} diff --git a/src/routes/docs/components/carousel.md b/src/routes/docs/components/carousel.md index 39fa46164..54b048dac 100644 --- a/src/routes/docs/components/carousel.md +++ b/src/routes/docs/components/carousel.md @@ -166,6 +166,26 @@ The `Carousel` exposes the `change` event containing info about the currently di ``` +## Carousel with links + +You can use `slot="slide"` and internal component `Slide` to control the image display. Here's an example how to wrap images with the anchor element. + +```svelte example + + +
+ + + + + + +
+``` + ## Customization ### Basic customization