Components
Dot Pagination
Dots for carousel pages, the active one stretched.
<DotPagination count={5} index={index} onChange={setIndex} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/dot-pagination.jsonimport { DotPagination } from "@/components/dot-pagination"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Dots for the pages of a carousel. The current one stretches into a pill, using a transform, so the row never shifts. Each dot is a button named "Slide 2 of 5".
import { DotPagination } from "@/components/dot-pagination";
export function Carousel({ slides }: { slides: React.ReactNode[] }) {
const [index, setIndex] = useState(0);
return (
<>
{slides[index]}
<DotPagination count={slides.length} index={index} onChange={setIndex} />
</>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
count | number | Number of pages. | |
index | number | The current page, from 0. | |
onChange | (index: number) => void | Called with the chosen page. | |
label | string | "Slides" | Accessible name; each dot is named after it. |
color | string | currentColor | Colour of the current dot. |
className | string | Classes for the nav. |
With reduced motion, the current dot changes without stretching.