navigationcontroller
z-sliderexperimentalSlider
Scroll-snap carousel for variable-width items, with drag/swipe, seamless looping, set-based paging, centered mode, and autoplay.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
sets | boolean | false | Navigates by viewport-wide sets of items instead of one item at a time; snap points land on set anchors. |
center | boolean | false | Centers the active item in the viewport instead of aligning it to the start. |
active-mode | 'all' | 'first' | 'all' | Which visible items get the active class: all visible items (default) or only the first. |
Inherited from CarouselBase
| Attribute | Type | Default | Description |
|---|---|---|---|
active | number | — | Index of the active slide; setting it navigates to that slide. -1 before initialization. |
finite | boolean | false | Stops at the first/last slide instead of looping; boundary controls are hidden and disabled. |
autoplay | boolean | false | Advances automatically every autoplay-interval ms; ticks pause while hovered, focused within, dragging, or the document is hidden. |
autoplay-interval | number | 7000 | Autoplay interval in milliseconds (minimum 500, default 7000). |
no-pause-on-hover | boolean | false | Keeps autoplay running while the pointer is over the carousel. |
no-drag | boolean | false | Disables pointer drag/swipe navigation. |
duration | number | 0 | Transition duration in ms. When unset, the component default (slider 350, slideshow 450) divided by velocity is used; an explicit 0 makes transitions instant. |
velocity | number | 1 | Speed multiplier applied to the default duration (default 1); ignored when duration is set. |
easing | string | '' | CSS easing for programmatic transitions; empty uses the component default. |
Inherited from Base
| Attribute | Type | Default | Description |
|---|---|---|---|
cls | string | '' | Adds classes to named parts as key: classes pairs; a plain string targets the default part. |
stl | string | '' | Adds inline styles to named parts as key: styles pairs; a plain string targets the default part. |
Custom Styling (cls / stl)
Default cls target:active · defaultstl target:host-inner
| Key | Default class | cls | stl | Description |
|---|---|---|---|---|
active | z-active | yes | no | Class applied to active slides and nav controls (default z-active). |
dragging | z-dragging | yes | no | Class applied to the items list while a pointer drag is in progress (default z-dragging). |
next | — | yes | no | Marker part for the next-arrow control (data-part="next"). |
previous | — | yes | no | Marker part for the previous-arrow control (data-part="previous"). |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-slider:before-change | Record<string, unknown> | cancelable, bubbles | Cancelable; fires before the active slide changes. Detail carries index, previousIndex, slide, previousSlide, value, and dir. |
z-slider:before-hide | Record<string, unknown> | cancelable, bubbles | Cancelable; fires before the outgoing slide hides, with the same detail as before-change. |
z-slider:before-show | Record<string, unknown> | cancelable, bubbles | Cancelable; fires before the incoming slide shows, with the same detail as before-change. |
z-slider:change | Record<string, unknown> | bubbles | Fires when the active slide changes, with the same detail as before-change. |
z-slider:hidden | Record<string, unknown> | bubbles | Fires after the outgoing slide's transition completes. |
z-slider:hide | Record<string, unknown> | bubbles | Fires when the outgoing slide starts hiding. |
z-slider:mount · from Controller | Record<string, unknown> | bubbles | Fires when deferred template content is mounted into the container. |
z-slider:show | Record<string, unknown> | bubbles | Fires when the incoming slide starts showing. |
z-slider:shown | Record<string, unknown> | bubbles | Fires after the incoming slide's transition completes. |
Methods
| Signature | Description |
|---|---|
count(): number | Returns the number of slides. |
index(): number | Returns the current active index. |
next(animate?: boolean = true): Promise<boolean> | Advances to the next slide (wraps unless finite); resolves to whether the index changed. |
previous(animate?: boolean = true): Promise<boolean> | Moves to the previous slide (wraps unless finite); resolves to whether the index changed. |
refresh(): void | Re-measures the track and re-initializes navigation, autoplay, and observers. |
show(target: number | 'next' | 'previous' | 'first' | 'last' | string, animate?: boolean = true): Promise<boolean> | Navigates to an index, next/previous/first/last, or a slide's data-value/id; resolves to whether the index changed. Cancelable before-* events can veto it. |
startAutoplay(): void | Starts the autoplay timer; a no-op unless autoplay is enabled. |
stopAutoplay(): void | Stops the autoplay timer. |
Data Hooks
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-auto-nav-item · from CarouselBase | — | descendant | config | Marks nav items generated by the carousel; a fully auto nav is rebuilt to match the slide count. |
data-autoplay · from CarouselBase | — | descendant | config | On a slide video: plays it while the slide is active. |
data-fn · from Controller | template | descendant | config | Marks a deferred <template> child whose content is mounted into the container on demand. |
data-keep-playing · from CarouselBase | — | descendant | config | On a slide video: keeps it playing when the slide becomes inactive. |
data-part · from CarouselBase | next, previous | descendant | marker | Marks arrow controls: data-part="previous" and data-part="next". |
data-value · from CarouselBase | — | descendant | read-only | On a slide: its command value, usable as a show() target and carried in event detail. |
CSS Classes
| Class | Role | Applies to | Description |
|---|---|---|---|
.z-dragging | state | .z-slider | State class on the track during a drag; disables snap and smooth scrolling. |
.z-slider | root | z-slider | Root class, also styled on the z-slider host. |
.z-slider-container | element | .z-slider | Optional outer wrapper clipping the track. |
.z-slider-items | element | .z-slider | The scrollable, scroll-snapping track holding the slides. |
Keyboard
| Keys | Action | When |
|---|---|---|
| ArrowLeft ArrowRight | Previous/next slide (direction flips in RTL). | — |
| ArrowLeft ArrowRight ArrowUp ArrowDown Home End | Move within a nav tablist; Home/End jump to the first/last slide. | Focus is inside a .z-slider-nav list. |
Accessibility
- The host is a
role="region"witharia-roledescription="carousel"; slides aretabpanels (with nav) orgroups labeledn of total. - Nav lists become
role="tablist"with roving tabindex; arrow controls getaria-controlsand localized labels. - The items list is
aria-live="polite", switched tooffwhile autoplay runs.