Fulldev UI

A thumbnail or dot that shows one slide of the shadcn/ui carousel and marks the current one.

Installation

npx shadcn@latest add @fulldev/carousel-indicator

This installs the shadcn/ui carousel too.

Usage

import { CarouselIndicator } from "@/components/ui/carousel-indicator"
<Carousel aria-label="Product images">
  <CarouselContent>
    <CarouselItem>...</CarouselItem>
    <CarouselItem>...</CarouselItem>
  </CarouselContent>
  <CarouselIndicator index={0}>...</CarouselIndicator>
  <CarouselIndicator index={1}>...</CarouselIndicator>
</Carousel>

CarouselIndicator goes inside Carousel and scrolls to the zero-based index, such as a thumbnail in a product gallery. The current one gets aria-current="true" and data-state="active". The index counts scroll positions, which are the slides when one shows at a time; an indicator without a position is hidden. Give it a size, such as size-14; an image inside fills it.

API Reference

Source: react/src/components/ui/carousel-indicator.tsx