Skip to content

Anatomy

Slider is a compound component. The root coordinates a track of items and any number of optional controls, all declared as child components. Use this map to see which parts exist and how they nest.

Structure

Slider                                 data-component="Slider"
├─ SliderDrag       [data-ref="wrapper"]   the draggable track      (required)
│  └─ SliderItem    (× n)                  a single slide           (required)
├─ SliderBtn        (× 2, prev / next)     navigation buttons       (optional)
├─ SliderCount                             current / total index    (optional)
├─ SliderDots                              secondary navigation     (optional)
└─ SliderProgress                          progress bar             (optional)

Parts

PartSelectorRequiredRole
Rootdata-component="Slider"YesOwns the index and drives every child.
Trackdata-component="SliderDrag"YesThe data-ref="wrapper" element holding the slides; enables drag.
Itemdata-component="SliderItem"Yes (× n)One slide.
Buttondata-component="SliderBtn"OptionalPrevious / next control.
Countdata-component="SliderCount"OptionalDisplays the current index.
Dotsdata-component="SliderDots"OptionalSecondary dot navigation.
Progressdata-component="SliderProgress"OptionalProgress indicator.

Registering the parts

SliderItem and SliderDrag are registered on Slider by default. To use any of the optional controls you must extend Slider and register the extra children yourself:

js
import {
  
Slider
as
SliderCore
,
SliderBtn
,
SliderCount
,
SliderDots
,
SliderDrag
,
SliderItem
,
SliderProgress
,
} from '@studiometa/ui'; export class
Slider
extends
SliderCore
{
static
config
= {
components
: {
SliderBtn
,
SliderCount
,
SliderDots
,
SliderDrag
,
SliderItem
,
SliderProgress
,
}, }; }

See the JavaScript API for the options exposed by each part.