INFINITYUI
HomeComponentsDocsTemplates
Star

Getting Started

  • Introduction
  • Installation
  • CLI
  • Audit

Navigation

  • Spotlight Navbar
  • Glass DockNEW
  • Animated Tab Bar
  • Circle Menu
  • Magnet Tabs
  • Animated Sidebar
  • Apple Spotlight
  • Page TOC RailNEW

Text

  • Flip Text
  • Glitch Text
  • Liquid Text
  • Flip Fade Text
  • Mask Cursor Effect

Cards

  • Glow Border Card
  • Testimonials Card
  • Interactive Book
  • Trading CardsNEW
  • Hover Image
  • Chain of ThoughtNEW
  • Masonry Grid
  • Image Pile
  • Staggered Grid

Inputs

  • AI InputNEW
  • OTP Input
  • Leave Rating

Buttons

  • Social Flip Button
  • Creepy Button

Loaders

  • Jelly Loader
  • Rolling Ball Scroll
  • Glowing Scroll

Backgrounds

  • Light Lines
  • Perspective Grid
  • Liquid Ocean
  • Eagle Vision
  • Flow Scroll
  • Horizontal Scroll

Overlays

  • PersonaNEW
  • Infinite Moving Cards
  • Masked Avatars
  • Stacked Logos
  • Icon Wheel
  • Pixelated CarouselNEW
  • Pixelated Image Trail
  • Flip Scroll
  • Interactive Folder
  • Animated Folder IconNEW
  • Stack Scroll
  • Rubik Cube
OverlaysNEW

Pixelated Carousel

#carousel#pixel#transition
Mountain Vista

Mountain Vista

Swiss Alps, 2024

implementedInfinityUI component

This component is fully implemented in InfinityUI and wired into the docs and registry flow.

Installation

Use the registry command to add the component source, and install any package dependencies if needed.

Infinity Registry

Install the component source into your project with the shadcn CLI.

npx shadcn@latest add https://infinityui-pearl.vercel.app/r/pixelated-carousel
Package Dependencies

Install the npm packages used by this component source.

npm install framer-motion

Component Code

Copy and paste this code into your component file.

tsx
"use client";

import { useState } from "react";
import { motion, AnimatePresence } from "framer-motion";

interface PixelatedCarouselProps {
    slides: Array<{ src: string; title: string; subtitle?: string }>;
}

export function PixelatedCarousel({ slides }: PixelatedCarouselProps) {
    const [current, setCurrent] = useState(0);
    const [direction, setDirection] = useState(1);
    const [transitioning, setTransitioning] = useState(false);

    const go = (next: number) => {
        if (transitioning) return;
        setDirection(next > current ? 1 : -1);
        setTransitioning(true);
        setCurrent(next);
        setTimeout(() => setTransitioning(false), 500);
    };

    const prev = () => go((current - 1 + slides.length) % slides.length);
    const next = () => go((current + 1) % slides.length);

    return (
        <div className="relative w-full overflow-hidden rounded-2xl border border-white/10 aspect-video bg-zinc-950">
            <AnimatePresence mode="wait" custom={direction}>
                <motion.div
                    key={current}
                    custom={direction}
                    initial={{ opacity: 0, filter: "blur(20px) saturate(0)", scale: 1.04 }}
                    animate={{ opacity: 1, filter: "blur(0px) saturate(1)", scale: 1 }}
                    exit={{ opacity: 0, filter: "blur(20px) saturate(0)", scale: 0.96 }}
                    transition={{ duration: 0.5, ease: "easeInOut" }}
                    className="absolute inset-0"
                >
                    <img
                        src={slides[current].src}
                        alt={slides[current].title}
                        className="w-full h-full object-cover"
                    />
                    <div className="absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent flex items-end p-8">
                        <div>
                            <h3 className="text-white text-2xl font-bold">{slides[current].title}</h3>
                            {slides[current].subtitle && (
                                <p className="text-zinc-300 text-sm mt-1">{slides[current].subtitle}</p>
                            )}
                        </div>
                    </div>
                </motion.div>
            </AnimatePresence>

            {/* Controls */}
            <button onClick={prev} className="absolute left-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-black/40 backdrop-blur border border-white/10 text-white flex items-center justify-center hover:bg-black/60 transition-colors z-10" aria-label="Previous">‹</button>
            <button onClick={next} className="absolute right-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-black/40 backdrop-blur border border-white/10 text-white flex items-center justify-center hover:bg-black/60 transition-colors z-10" aria-label="Next">›</button>

            {/* Dots */}
            <div className="absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-1.5 z-10">
                {slides.map((_, i) => (
                    <button key={i} onClick={() => go(i)} className={`h-1.5 rounded-full transition-all duration-300 ${i === current ? "w-6 bg-white" : "w-1.5 bg-white/40 hover:bg-white/60"}`} aria-label={`Go to slide ${i + 1}`} />
                ))}
            </div>
        </div>
    );
}