Introducing Aceternity UI Pro - 70+ premium component packs and templates to build amazing websites.
Logo

Apple Cards Carousel

A sleek and minimal carousel implementation, as seen on apple.com

Open in

Get to know your iSad.

Installation

Run the following command

npx shadcn@latest add https://ui.aceternity.com/registry/apple-cards-carousel.json

Add useOutsideClick hook

hooks/use-outside-click.ts
import React, { useEffect } from "react";
 
export const useOutsideClick = (
  ref: React.RefObject<HTMLDivElement>,
  callback: Function
) => {
  useEffect(() => {
    const listener = (event: any) => {
      if (!ref.current || ref.current.contains(event.target)) {
        return;
      }
      callback(event);
    };
 
    document.addEventListener("mousedown", listener);
    document.addEventListener("touchstart", listener);
 
    return () => {
      document.removeEventListener("mousedown", listener);
      document.removeEventListener("touchstart", listener);
    };
  }, [ref, callback]);
};

Examples

Standard

Open in

Get to know your iSad.

With Layout Changes

Open in

Get to know your iSad.

Props

PropTypeDefaultDescription
itemsJSX.Element[]RequiredArray of JSX elements to be displayed in the carousel
initialScrollnumber0Initial scroll position of the carousel

Card Component

PropTypeDefaultDescription
cardCardRequiredObject containing card details (src, title, category, content)
indexnumberRequiredIndex of the card in the carousel
layoutbooleanfalseWhether to use layout animations

BlurImage Component

PropTypeDefaultDescription
heightnumber | string-Height of the image
widthnumber | string-Width of the image
srcstringRequiredSource URL of the image
classNamestring-Additional CSS classes for the image
altstring"Background of a beautiful view"Alt text for the image
...restImageProps-Any other props accepted by Next.js Image component

Note: The Card type is defined as:

type Card = {
  src: string;
  title: string;
  category: string;
  content: React.ReactNode;
};

Build websites faster and 10x better than your competitors with Aceternity UI Pro

With the best in class components and templates, stand out from the crowd and get more attention to your website. Trusted by founders and entrepreneurs from all over the world.

Go Pro
Excellent communication and professionalism from the start and throughout. Happily and calmly accepted and entertained a few additional out-of-scope requests as well. Good open-...

Henrik Söderlund

Former CTO at Creme Digital

A product by Aceternity
Building in public at @mannupaaji