opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Gallery
  4. Gallery Grid
Back to Gallery

Components / Gallery

Gallery Grid

Free Gallery React component — GalleryGridCard. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Album preview with title, subtitle, and a three-cell photo grid — last cell shows a +N overflow count. Portfolio and gallery index pages.

Preview

Summer Collection

24 photos · Jun 2026

Summer Collection
Summer Collection
Summer Collection
+21

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/gallery/gallery-grid-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { GalleryGridCard } from "@/components/gallery/gallery-grid-card";

    <GalleryGridCard />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/gallery/gallery-grid-card.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
import Image from "next/image";
 
import { cn } from "@/lib/cn";
 
import { Sun } from "lucide-react";
 
export type GalleryGridCardProps = Readonly<
{
title?: string;
subtitle?: string;
count?: string | number;
images?: string[];
overlayText?: string;
icon?: ReactNode;
} & ComponentPropsWithoutRef<"div">
>;
 
// Production-ready Gallery Grid component — styled with Tailwind CSS.
export const GalleryGridCard = forwardRef<HTMLDivElement, GalleryGridCardProps>(
(
{
className,
title = "Summer Collection",
subtitle = "Jun 2026",
count = "24 photos",
images = ["/wallpaper-15.png", "/wallpaper-3.png", "/wallpaper-11.png"],
overlayText = "+21",
icon,
...props
},
ref,
) => {
return (
<div
ref={ref}
data-slot="gallery-grid-card"
className={cn(
"w-72 overflow-hidden rounded-2xl border border-neutral-100 bg-white font-sans shadow-lg",
className,
)}
{...props}
>
<div className="flex items-center justify-between p-3 pb-2">
<div>
<h3 className="text-sm font-semibold text-neutral-900">{title}</h3>
 
<p className="text-[10px] text-neutral-400">
{count} · {subtitle}
</p>
</div>
 
{icon ?? <Sun className="text-neutral-500" size={16} />}
</div>
 
{/* Grid */}
<div className="grid grid-cols-3 gap-1 px-3 pb-3">
{/* Main large image */}
<div className="relative col-span-2 row-span-2 aspect-square overflow-hidden rounded-xl">
<Image
src={images[0]}
alt={title}
fill
sizes="288px"
className="object-cover transition-transform duration-500 hover:scale-105"
/>
</div>
 
{/* Small image 1 */}
<div className="relative aspect-square overflow-hidden rounded-xl">
<Image
src={images[1]}
alt={title}
fill
sizes="96px"
className="object-cover"
/>
</div>
 
{/* Small image 2 with overlay */}
<div className="relative aspect-square overflow-hidden rounded-xl">
<Image
src={images[2]}
alt={title}
fill
sizes="96px"
className="object-cover"
/>
 
<div className="absolute inset-0 flex items-center justify-center bg-black/50">
<span className="text-xs font-semibold text-white">
{overlayText}
</span>
</div>
</div>
</div>
</div>
);
},
);
 
GalleryGridCard.displayName = "GalleryGridCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/gallery/gallery-grid-card.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.