Skip to main content

<SliderDotGroup/>

This a customizable dot group component for the slider.

Import

import {SliderBarDotGroup, renderDotsDynamicCircle} from "react-scroll-snap-anime-slider";

Usage

An example to use dynamic circle as dot group by using renderDotsDynamicCircle as a dot rendering function:

<SliderBarDotGroup
id="my-slider-dot-group"
className="my-class-name"
aria-label="slider bar"
dotGroupProps={{
id: "my-slider-bar-dot-group",
}}
renderDots={renderDotsDynamicCircle}
/>

Also there is a renderDotsDynamicPill which will render dot as a pill:

import {SliderBarDotGroup, renderDotsDynamicPill} from "react-scroll-snap-anime-slider";

Props

NameTypeRequiredDefaultDescription
Any DIV PropsReact.HTMLAttributes<HTMLDivElement>NoDIV Element props
dotGroupPropsReact.HTMLAttributes<HTMLDivElement>NoProps to the dot group DIV
renderDots(props: IRenderDotsProps) => JSX.Element / JSX.Element[]NoTo customize the dot group rendering by using the state props passed in

Other Props

IRenderDotsProps

NameTypeDescription
totalSlidesnumberTotal slides in this slider
currentSlidenumberCurrent slide index (from 0 ~ (length - visible slide - 1))
visibleSlidesnumberHow many visible slides (N), then the slide width = 100% / N
stepnumberHow mange slides per step (when click previous and next button)
leftnumberHow far has scrolled in %, range in [0 ~ (100 - % of visible slides)]
slideTo(slideIndex: number) => voidA function to call to control the slider to slide to a target slide
From 0 ~ (length - visible slide - 1)
If no customized function is provided, a default function will be used

A starter example:

MyDotGroup.tsx
import {SliderBarDotGroup, IRenderDotsProps} from "react-scroll-snap-anime-slider";

function myRenderDots(props: IRenderDotsProps) {
let {
visibleSlides,
totalSlides,
step,
left,
currentSlide,
slideTo,
} = props;

let dots: JSX.Element[] = [];

for (let i = 0; i < totalSlides; ++i) {
// your customization code to get customized style

dots.push(
<div
className="my-dot-class"
key={i}
style={// customized style}
onClick={() => {
slideTo(i);
}}
/>
);
}
return dots;
}

export function MyDotGroup(){
return (
<SliderBarDotGroup
renderDots={myRenderDots}
/>
);
}

CSS

You can override the default style by using these class names.

Rule NameDescription
.rssas-slider-barFor bar wrapper
.rssas-slider-bar-dot-groupFor dot group DIV
.rssas-slider-dot-wrapperFor dot wrapper DIV
.rssas-activeFor dot wrapper DIV that is active
.rssas-dynamicFor dot wrapper DIV that has dynamic dot
.rssas-slider-dotFor dot DIV