Skip to content

TkxCarousel

Single slide with dots
Mountain at dawn
Mountain at dawn
import { TkxCarousel, TkxCarouselSlide } from 'tekivex-ui';
<TkxCarousel>
<TkxCarouselSlide>
<img src="/slide-1.jpg" alt="Mountain at dawn" />
</TkxCarouselSlide>
<TkxCarouselSlide>
<img src="/slide-2.jpg" alt="Forest path" />
</TkxCarouselSlide>
<TkxCarouselSlide>
<img src="/slide-3.jpg" alt="Coastline" />
</TkxCarouselSlide>
</TkxCarousel>
Autoplay (pauses on hover/focus)
Mountain at dawn
Mountain at dawn
<TkxCarousel autoplay autoplayInterval={5000} pauseOnHover>
{/* slides */}
</TkxCarousel>

Autoplay pauses on hover, focus, AND when the user prefers reduced motion (prefers-reduced-motion: reduce is automatic).

<TkxCarousel indicators="dots"> {/* default — small dots */}
<TkxCarousel indicators="bars"> {/* progress bars */}
<TkxCarousel indicators="numbers"> {/* "1 / 5" counter */}
<TkxCarousel indicators="none"> {/* no indicators */}

Show multiple slides at once (e.g. product cards):

<TkxCarousel slidesPerView={3} gap={16}>
{products.map(p => (
<TkxCarouselSlide key={p.id}>
<ProductCard product={p} />
</TkxCarouselSlide>
))}
</TkxCarousel>

slidesPerView accepts a number or a responsive object:

<TkxCarousel
slidesPerView={{ base: 1, md: 2, lg: 3, xl: 4 }}
gap={16}
>
<TkxCarousel loop>
{/* infinite loop — going past the last slide returns to the first */}
</TkxCarousel>
const [active, setActive] = useState(0);
<TkxCarousel active={active} onChange={setActive}>
{/* … */}
</TkxCarousel>
  • Carousel container: role="region" + aria-roledescription="carousel"
  • Each slide: role="group" + aria-roledescription="slide" + aria-label="Slide N of M"
  • Live region announces slide changes to screen readers
  • Previous / Next buttons with localised aria-labels
  • Indicator buttons have aria-current="true" on the active one
  • Keyboard:
    • Left / Right — previous / next slide
    • Home / End — first / last slide
  • Pause on focus — autoplay always pauses when keyboard focus enters the carousel (required for WCAG 2.2.2)
PropTypeRequiredDescription
autoplaybooleanDefaults to false.
autoplayIntervalnumberms between slides. Defaults to 5000.
pauseOnHoverbooleanDefaults to true when autoplay is on.
loopbooleanWrap from last to first slide.
slidesPerViewnumber | Record<Breakpoint, number>Defaults to 1.
gapnumberGap between slides in px.
indicators'dots' | 'bars' | 'numbers' | 'none'Defaults to dots.
activenumberControlled active slide index.
onChange(index: number) => voidActive slide change.

src/components/TkxCarousel.tsx