navigationcontrollerz-sliderexperimental

Slider

Scroll-snap carousel for variable-width items, with drag/swipe, seamless looping, set-based paging, centered mode, and autoplay.

Attributes

AttributeTypeDefaultDescription
setsbooleanfalseNavigates by viewport-wide sets of items instead of one item at a time; snap points land on set anchors.
centerbooleanfalseCenters 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
AttributeTypeDefaultDescription
activenumber—Index of the active slide; setting it navigates to that slide. -1 before initialization.
finitebooleanfalseStops at the first/last slide instead of looping; boundary controls are hidden and disabled.
autoplaybooleanfalseAdvances automatically every autoplay-interval ms; ticks pause while hovered, focused within, dragging, or the document is hidden.
autoplay-intervalnumber7000Autoplay interval in milliseconds (minimum 500, default 7000).
no-pause-on-hoverbooleanfalseKeeps autoplay running while the pointer is over the carousel.
no-dragbooleanfalseDisables pointer drag/swipe navigation.
durationnumber0Transition duration in ms. When unset, the component default (slider 350, slideshow 450) divided by velocity is used; an explicit 0 makes transitions instant.
velocitynumber1Speed multiplier applied to the default duration (default 1); ignored when duration is set.
easingstring''CSS easing for programmatic transitions; empty uses the component default.
Inherited from Base
AttributeTypeDefaultDescription
clsstring''Adds classes to named parts as key: classes pairs; a plain string targets the default part.
stlstring''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

KeyDefault classclsstlDescription
activez-activeyesnoClass applied to active slides and nav controls (default z-active).
draggingz-draggingyesnoClass applied to the items list while a pointer drag is in progress (default z-dragging).
next—yesnoMarker part for the next-arrow control (data-part="next").
previous—yesnoMarker part for the previous-arrow control (data-part="previous").

Events

EventDetailFlagsDescription
z-slider:before-changeRecord<string, unknown>cancelable, bubblesCancelable; fires before the active slide changes. Detail carries index, previousIndex, slide, previousSlide, value, and dir.
z-slider:before-hideRecord<string, unknown>cancelable, bubblesCancelable; fires before the outgoing slide hides, with the same detail as before-change.
z-slider:before-showRecord<string, unknown>cancelable, bubblesCancelable; fires before the incoming slide shows, with the same detail as before-change.
z-slider:changeRecord<string, unknown>bubblesFires when the active slide changes, with the same detail as before-change.
z-slider:hiddenRecord<string, unknown>bubblesFires after the outgoing slide's transition completes.
z-slider:hideRecord<string, unknown>bubblesFires when the outgoing slide starts hiding.
z-slider:mount · from ControllerRecord<string, unknown>bubblesFires when deferred template content is mounted into the container.
z-slider:showRecord<string, unknown>bubblesFires when the incoming slide starts showing.
z-slider:shownRecord<string, unknown>bubblesFires after the incoming slide's transition completes.

Methods

SignatureDescription
count(): numberReturns the number of slides.
index(): numberReturns 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(): voidRe-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(): voidStarts the autoplay timer; a no-op unless autoplay is enabled.
stopAutoplay(): voidStops the autoplay timer.

Data Hooks

AttributeValuesApplies toRoleDescription
data-auto-nav-item · from CarouselBase—descendantconfigMarks nav items generated by the carousel; a fully auto nav is rebuilt to match the slide count.
data-autoplay · from CarouselBase—descendantconfigOn a slide video: plays it while the slide is active.
data-fn · from ControllertemplatedescendantconfigMarks a deferred <template> child whose content is mounted into the container on demand.
data-keep-playing · from CarouselBase—descendantconfigOn a slide video: keeps it playing when the slide becomes inactive.
data-part · from CarouselBasenext, previousdescendantmarkerMarks arrow controls: data-part="previous" and data-part="next".
data-value · from CarouselBase—descendantread-onlyOn a slide: its command value, usable as a show() target and carried in event detail.

CSS Classes

ClassRoleApplies toDescription
.z-draggingstate.z-sliderState class on the track during a drag; disables snap and smooth scrolling.
.z-sliderrootz-sliderRoot class, also styled on the z-slider host.
.z-slider-containerelement.z-sliderOptional outer wrapper clipping the track.
.z-slider-itemselement.z-sliderThe scrollable, scroll-snapping track holding the slides.

Keyboard

KeysActionWhen
ArrowLeft ArrowRightPrevious/next slide (direction flips in RTL).—
ArrowLeft ArrowRight ArrowUp ArrowDown Home EndMove 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" with aria-roledescription="carousel"; slides are tabpanels (with nav) or groups labeled n of total.
  • Nav lists become role="tablist" with roving tabindex; arrow controls get aria-controls and localized labels.
  • The items list is aria-live="polite", switched to off while autoplay runs.