Skip to content

Develop

A count indicator shows the current position within a set of items using dots and optional navigation controls.

<div class="tng-count-indicator">
<div class="tng-count-indicator-helper">1 of 10</div>
<div class="tng-count-indicator-dots">
<div class="is-current"></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="tng-count-indicator-buttons">
<button class="tng-icon-button is-sm" aria-label="Previous">
<i class="tng-icon icon-chevron-left" aria-hidden="true"></i>
</button>
<button class="tng-icon-button is-sm" aria-label="Next">
<i class="tng-icon icon-chevron-right" aria-hidden="true"></i>
</button>
</div>
</div>
1 of 10

Import the CountIndicator component from @tmedxp/react-components.

PropTypeDescriptionRequired
totalnumberTotal number of items.
indexnumberZero-based current item index.
onPrev() => voidPrevious action callback.
onNext() => voidNext action callback.
wrapbooleanLoops navigation at boundaries.
showHelperbooleanShow X of Y helper text. Default true.
showButtonsbooleanShow previous/next buttons. Default true.
showDotsbooleanShow dots indicator. Default true.
maxDotsnumberMaximum number of rendered dots. Default 10.
semanticDotsbooleanUse 1:1 semantic dots when total <= maxDots. Default true.
ariaLabelstringLabel for the root group.
ariaLabelDotsstringLabel for dots group.
prevAriaLabelstringPrevious button aria-label.
nextAriaLabelstringNext button aria-label.
helperOfLabelstringTranslation for of in helper text.
classNamestringExtra class name for root element.
import { useState } from 'react';
import { CountIndicator } from '@tmedxp/react-components';
const CountIndicatorDefaultExample = () => {
const total = 10;
const [index, setIndex] = useState(0);
return (
<CountIndicator
total={total}
index={index}
ariaLabel="count indicator"
ariaLabelDots="progress"
prevAriaLabel="previous"
nextAriaLabel="next"
helperOfLabel="of"
onPrev={() => setIndex((i) => Math.max(0, i - 1))}
onNext={() => setIndex((i) => Math.min(total - 1, i + 1))}
/>
);
};
export { CountIndicatorDefaultExample };
import { CountIndicator } from '@tmedxp/react-components';
const CountIndicatorSimpleExample = () => {
return (
<CountIndicator
total={42}
index={5}
onPrev={() => {}}
onNext={() => {}}
showButtons={false}
maxDots={5}
ariaLabel="count indicator"
ariaLabelDots="progress"
prevAriaLabel="previous"
nextAriaLabel="next"
helperOfLabel="of"
/>
);
};
export { CountIndicatorSimpleExample };