Shadix UIImage Gallery

Image Gallery

A responsive masonry image gallery component with lazy loading and lightbox integration.

Who Developed This Component:

Installation

GitHub
pnpm dlx shadcn@latest add @shadix-ui/image-gallery

Usage

Basic Usage

Import the Component

import { ImageGallery, type ImageItem } from '@/components/image-gallery';

Use the Component

import { ImageGallery, type ImageItem } from '@/components/image-gallery';

const images: ImageItem[] = [
    {
        src: '/image1.jpg',
        alt: 'Image 1'
    },
    {
        src: '/image2.jpg',
        alt: 'Image 2'
    }
    // ... more images
];

export default function MyGallery() {
    return <ImageGallery images={images} />;
}

With Custom Columns

<ImageGallery
    images={images}
    columns={{
        desktop: 4,
        tablet: 2,
        mobile: 1
    }}
    gap={20}
/>

With Filtering

<ImageGallery images={images} filterImages={(image) => !image.alt.includes('private')} />

With Sorting

<ImageGallery images={images} sortImages={(a, b) => a.alt.localeCompare(b.alt)} />

With Click Handler

<ImageGallery
    images={images}
    onImageClick={(image, index) => {
        console.log(`Clicked: ${image.alt}`);
    }}
/>

Disable Lazy Loading

<ImageGallery images={images} lazyLoading={false} />

Props

Built by Gihan (apix-js) for Shadcn at Vercel. Source code on GitHub.