opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Instagram
  4. Instagram Post
Back to Instagram

Components / Instagram

Instagram Post

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

Full Instagram post layout — header, square image, action icons, like count, caption, and timestamp. Looks native, props for your content.

Preview

User avatar

bidyut.dev

West Bengal, India

Instagram post image

1,204 likes

bidyut.dev New card UI drop. Minimal, clean, and open-source. #uidesign #reactjs #webdev

2 hours ago

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/instagram/instagram-post-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { InstagramPostCard } from "@/components/instagram/instagram-post-card";

    <InstagramPostCard username="you" caption="Your caption" avatar="/avatar.png" postImage="/post.jpg" />

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/instagram/instagram-post-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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
"use client";
 
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
import Image from "next/image";
 
import { cn } from "@/lib/cn";
 
import {
Ellipsis,
ThumbsUp,
MessageCircle,
Bookmark,
Share2,
} from "lucide-react";
 
export type InstagramPostCardProps = Readonly<
{
username?: string;
location?: string;
likes?: number;
caption?: string;
hashtags?: string;
timestamp?: string;
avatar?: string;
postImage?: string;
avatarAlt?: string;
imageAlt?: string;
imagePriority?: boolean;
likeIcon?: ReactNode;
commentIcon?: ReactNode;
shareIcon?: ReactNode;
bookmarkIcon?: ReactNode;
onLike?: () => void;
onComment?: () => void;
onShare?: () => void;
onBookmark?: () => void;
} & ComponentPropsWithoutRef<"div">
>;
 
// Production-ready Instagram Post component — styled with Tailwind CSS.
export const InstagramPostCard = forwardRef<
HTMLDivElement,
InstagramPostCardProps
>(
(
{
className,
username = "bidyut.dev",
location = "West Bengal, India",
likes = 1204,
caption = "New card UI drop. Minimal, clean, and open-source.",
hashtags = "#uidesign #reactjs #webdev",
timestamp = "2 hours ago",
avatar = "/profile-picture.png",
postImage = "/wallpaper-3.png",
avatarAlt = "User avatar",
imageAlt = "Instagram post image",
imagePriority = false,
likeIcon,
commentIcon,
shareIcon,
bookmarkIcon,
onLike,
onComment,
onShare,
onBookmark,
...props
},
ref,
) => {
return (
<div
ref={ref}
data-slot="instagram-post-card"
className={cn(
"w-xs overflow-hidden rounded-xl border border-neutral-100 bg-white font-sans shadow-lg",
className,
)}
{...props}
>
{/* Profile header */}
<div
data-slot="instagram-post-card-header"
className="flex items-center gap-2 px-3 py-2.5"
>
<div className="h-8 w-8 rounded-full bg-linear-to-tr from-yellow-400 via-pink-500 to-blue-600 p-0.5">
<div className="h-full w-full rounded-full bg-white p-0.5">
<div className="flex h-full w-full items-center justify-center rounded-full bg-neutral-900">
<Image
src={avatar}
alt={avatarAlt}
width={16}
height={16}
className="w-4"
sizes="16px"
/>
</div>
</div>
</div>
 
<div>
<p
title={username}
className="text-xs font-semibold text-neutral-900"
>
{username}
</p>
 
<p title={location} className="text-[10px] text-neutral-400">
{location}
</p>
</div>
 
<button
type="button"
aria-label="More options"
className="ml-auto cursor-pointer text-neutral-400"
>
<Ellipsis size={15} aria-hidden />
</button>
</div>
 
{/* Post image */}
<div className="relative h-36 w-full">
<Image
data-slot="instagram-post-card-image"
src={postImage}
alt={imageAlt}
fill
className="object-cover"
sizes="320px"
priority={imagePriority}
/>
</div>
 
{/* Post content */}
<div className="px-3 pt-2.5 pb-3">
{/* Engagement actions */}
<div
data-slot="instagram-post-card-actions"
className="mb-2 flex items-center justify-between"
>
<div className="flex items-center gap-3">
<button
type="button"
aria-label={`Like post from ${username}`}
onClick={onLike}
className="cursor-pointer text-neutral-700 transition-colors hover:text-black"
>
{likeIcon ?? <ThumbsUp size={15} />}
</button>
 
<button
type="button"
aria-label={`Comment on post from ${username}`}
onClick={onComment}
className="cursor-pointer text-neutral-700 transition-colors hover:text-black"
>
{commentIcon ?? <MessageCircle size={15} />}
</button>
 
<button
type="button"
aria-label={`Share post from ${username}`}
onClick={onShare}
className="cursor-pointer text-neutral-700 transition-colors hover:text-black"
>
{shareIcon ?? <Share2 size={15} />}
</button>
</div>
 
<button
type="button"
aria-label={`Save post from ${username}`}
onClick={onBookmark}
className="cursor-pointer text-neutral-700 transition-colors hover:text-black"
>
{bookmarkIcon ?? <Bookmark size={15} />}
</button>
</div>
 
<p className="mb-1 text-xs font-semibold text-neutral-900">
{likes.toLocaleString("en-US")} likes
</p>
 
<p className="text-xs leading-relaxed text-neutral-800">
<span className="font-semibold">{username}</span> {caption}{" "}
<span className="text-blue-500">{hashtags}</span>
</p>
 
<p className="mt-1 text-[10px] tracking-wide text-neutral-400 uppercase">
{timestamp}
</p>
</div>
</div>
);
},
);
 
InstagramPostCard.displayName = "InstagramPostCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/instagram/instagram-post-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.