Skip to content
My content My content My content My content My content My content My content My content
Carousel - Web Component
The Carousel component can be used imported from:
Playground
Parameters
The Web component uses the <z-carousel>
tag:
By default, all the parameters are optional or can be set in different, except for the ones marked as required
The parametrization of the component can be done with the following custom HTML params:
Name | Type | Description | Slot | A11y |
---|---|---|---|---|
config | string | Carousel configuration | ||
overflow | boolean | |||
no-loop | boolean | |||
items | number | Number of items | ||
delay | number | Delay between slides. Minimum value must be 1000ms |
Events
This component has events. Check the documentation about how to use the events.
Name | Payload | Description |
---|---|---|
change | number | Fires when the slide changes |
Slots
This component has slots. Check the documentation about how to use the slots.
Name | Tags | Description |
---|---|---|
slide-<number> | span | Slot for the slide content. The number is the index of the slide. |
Parameters use
config
The config
attribute is used to customize the interaction components of the carousel. The interaction components are the dots and the navigation arrows.
The first modifier is the arrows
styling. The possible values are: circle
, chevron
or semi
.
The second modifier is the dots
position. Possible values are: center
, left
, right
.
The third modifier adds navigation to the dots using nav
. Requires some dots
config.
You can combine the two modifiers separating them with a (:
). The patter would be <?arrows>:<?dots>:<?nav>
.
delay
The delay
attribute is used to define the time in milliseconds between each slide.
Slides
Make sure for each slide to use the slot
attribute with the value slide-<number>
. The number should be incremental.
Special uses
Card gallery
We can create nice galleries using the overflow version of Carousel
. We recommend to set the no-loop
flag and play with the --z-carousel--squint
value. The gallery navigation can be done in chunks, where those have the same gap as the carousel slides to make a continuos effect.
So adding some style:
scss
#my-gallery {
width: calc(100% - var(--zs-600));
margin: 0 auto;
> [slot^="slide-"] {
grid-template-columns: 1fr 1fr 1fr;
gap: var(--zs-100);
}
}
We can the write the component:
Browser support
Detected engine:
Chromium
Webkit
Gecko