All components

Carousel

Carousel is a React and Tailwind CSS media component from Motion Primitives, licensed MIT. Copy it and paste it into your project.

Motion Primitives MIT media

What it is

Carousel is a React and Tailwind CSS media component from Motion Primitives, licensed MIT. Copy it and paste it into your project.

How to use it

Open it in the catalogue, press copy, and paste it into your project. The prompt you copy carries the code and the rules that tell your agent to reproduce it without changing anything.

Open in the catalogue

Four free copies a week. No card.

No packages beyond the project baseline

Licence

This component comes from Motion Primitives and is redistributed under the MIT licence, which permits commercial use. The copyright notice travels with the code.

Carousel

app/docs/carousel/carousel-custom-indicator.tsx
'use client';
import {
  Carousel,
  CarouselContent,
  CarouselItem,
} from '@/components/core/carousel';
import { useState } from 'react';

const ITEMS = new Array(4).fill(null).map((_, index) => index + 1);

export function CarouselCustomIndicator() {
  const [index, setIndex] = useState(0);

  return (
    <div className='relative w-full max-w-xs py-8'>
      <Carousel index={index} onIndexChange={setIndex}>
        <CarouselContent className='relative'>
          {ITEMS.map((item) => {
            return (
              <CarouselItem key={item} className='p-4'>
                <div className='flex aspect-square items-center justify-center border border-zinc-200 dark:border-zinc-800'>
                  {item}
                </div>
              </CarouselItem>
            );
          })}
        </CarouselContent>
      </Carousel>
      <div className='flex w-full justify-center space-x-3 px-4'>
        {ITEMS.map((item) => {
          return (
            <button
              key={item}
              type='button'
              aria-label={`Go to slide ${item}`}
              onClick={() => setIndex(item - 1)}
              className='h-12 w-12 border border-zinc-200 dark:border-zinc-800'
            >
              {item}
            </button>
          );
        })}
      </div>
    </div>
  );
}

Similar components