Styled text counter
renderCustom lets you return any HTML string as the pagination. The function receives current and total on every slide change.
View code
<div class="c--slider-a" id="my-slider">
<div class="c--slider-a__wrapper">
<div class="c--slider-a__slide">1</div>
<div class="c--slider-a__slide">2</div>
<div class="c--slider-a__slide">3</div>
</div>
</div>
<div id="my-pag" class="c--slider-a__pagination custom-pag"></div> .c--slider-a { position: relative; width: 100%; overflow: hidden; }
.c--slider-a__wrapper { display: flex; will-change: transform; }
.c--slider-a__slide { flex-shrink: 0; width: 100%; height: 260px; }
.custom-pag { font-size: 1.1rem; font-weight: 300; color: #374151; padding: 12px 0; text-align: center; }
.custom-pag strong { font-size: 1.8rem; font-weight: 800; color: #6C2BD9; }
.custom-pag span { color: #9ca3af; font-size: 0.85rem; } .custom-pag {
font-size: 1.1rem;
font-weight: 300;
color: #374151;
padding: 12px 0;
text-align: center;
}
.custom-pag strong {
font-size: 1.8rem;
font-weight: 800;
color: #6C2BD9;
}
.custom-pag span {
color: #9ca3af;
font-size: 0.85rem;
}
.c--slider-a {
position: relative;
width: 100%;
overflow: hidden;
&__wrapper {
display: flex;
will-change: transform;
}
&__slide {
flex-shrink: 0;
width: 100%;
height: 260px;
}
} import { Slider } from '@andresclua/sliderkit'
import { arrows, pagination } from '@andresclua/sliderkit-plugins'
new Slider('#my-slider', {
loop: false,
rewind: true,
plugins: [
arrows(),
pagination({
el: '#my-pag',
type: 'custom',
renderCustom: ({ current, total }) =>
'<strong>' + current + '</strong> <span>of ' + total + '</span>',
}),
],
}) Step indicator
A step indicator renders numbered bubbles showing current progress. Use renderCustom with a loop to generate each step pill dynamically.
View code
<div class="c--slider-a" id="my-slider">
<div class="c--slider-a__wrapper">
<div class="c--slider-a__slide">Step 1</div>
<div class="c--slider-a__slide">Step 2</div>
<div class="c--slider-a__slide">Step 3</div>
<div class="c--slider-a__slide">Step 4</div>
</div>
</div>
<div id="my-pag" class="step-pag"></div> .c--slider-a { position: relative; width: 100%; overflow: hidden; }
.c--slider-a__wrapper { display: flex; will-change: transform; }
.c--slider-a__slide { flex-shrink: 0; width: 100%; height: 260px; }
.step-pag { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 16px 0; }
.step-bubble { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; background: #e5e7eb; color: #6b7280; }
.step-bubble.is-done { background: #6C2BD9; color: #fff; }
.step-bubble.is-active { background: #fff; border: 2px solid #6C2BD9; color: #6C2BD9; }
.step-line { width: 32px; height: 2px; background: #e5e7eb; }
.step-line.is-done { background: #6C2BD9; } .step-pag {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
padding: 16px 0;
}
.step-bubble {
width: 28px;
height: 28px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 700;
background: #e5e7eb;
color: #6b7280;
}
.step-bubble.is-done {
background: #6C2BD9;
color: #fff;
}
.step-bubble.is-active {
background: #fff;
border: 2px solid #6C2BD9;
color: #6C2BD9;
}
.step-line {
width: 32px;
height: 2px;
background: #e5e7eb;
}
.step-line.is-done {
background: #6C2BD9;
}
.c--slider-a {
position: relative;
width: 100%;
overflow: hidden;
&__wrapper {
display: flex;
will-change: transform;
}
&__slide {
flex-shrink: 0;
width: 100%;
height: 260px;
}
} import { Slider } from '@andresclua/sliderkit'
import { arrows, pagination } from '@andresclua/sliderkit-plugins'
function buildSteps(current, total) {
let html = ''
for (let i = 1; i <= total; i++) {
if (i > 1) {
const lineClass = i <= current ? 'step-line is-done' : 'step-line'
html += '<span class="' + lineClass + '"></span>'
}
const cls = i < current ? 'is-done' : i === current ? 'is-active' : ''
html += '<span class="step-bubble ' + cls + '">' + i + '</span>'
}
return html
}
new Slider('#my-slider', {
loop: false,
rewind: false,
plugins: [
arrows(),
pagination({
el: '#my-pag',
type: 'custom',
renderCustom: ({ current, total }) => buildSteps(current, total),
}),
],
})