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

Components / Facebook

Threads Post

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

Threads-style post with avatar thread line, text, optional image, and engagement counts. Like toggles on tap.

Preview

bidyut.dev
bidyut.dev1h

Just dropped 14 new email & editor widgets. All white background, all interactive. Which one should I build next?

Thread attachment

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

  4. 4

    Import and render:

    Example

    import { ThreadsPostCard } from "@/components/facebook/threads-post-card";

    <ThreadsPostCard username="you" content="Your thread text" avatar="/avatar.png" />

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/facebook/threads-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
"use client";
 
import { forwardRef, useState, type ComponentPropsWithoutRef } from "react";
import Image from "next/image";
 
import { cn } from "@/lib/cn";
 
import { Heart, MessageCircle, Repeat, Send } from "lucide-react";
 
export type ThreadsPostCardProps = Readonly<
{
username?: string;
content?: string;
time?: string;
likes?: number;
replies?: number;
avatar?: string;
postImage?: string;
showImage?: boolean;
onLike?: () => void;
} & ComponentPropsWithoutRef<"div">
>;
 
// Production-ready Threads Post component — styled with Tailwind CSS.
export const ThreadsPostCard = forwardRef<HTMLDivElement, ThreadsPostCardProps>(
(
{
className,
username = "bidyut.dev",
content = "Just dropped 14 new email & editor widgets. All white background, all interactive. Which one should I build next?",
time = "1h",
likes = 892,
replies = 47,
avatar = "/profile-picture.png",
postImage = "/wallpaper-3.png",
showImage = true,
onLike,
...props
},
ref,
) => {
const [liked, setLiked] = useState(false);
const [likeCount, setLikeCount] = useState(likes);
 
return (
<div
ref={ref}
data-slot="threads-post-card"
className={cn(
"w-72 rounded-2xl border border-neutral-100 bg-white p-4 font-sans shadow-lg",
className,
)}
{...props}
>
<div className="flex gap-3">
<div className="flex flex-col items-center">
<div className="h-10 w-10 overflow-hidden rounded-full ring-2 ring-neutral-100">
<Image
src={avatar}
alt={username}
width={40}
height={40}
className="object-cover"
/>
</div>
<div className="mt-1 w-px flex-1 bg-neutral-200" />
</div>
 
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
<span className="text-[13px] font-semibold text-neutral-900">
{username}
</span>
<span className="text-[11px] text-neutral-400">{time}</span>
</div>
<p className="mt-1.5 text-[13px] leading-relaxed text-neutral-800">
{content}
</p>
 
{showImage && (
<div className="relative mt-2.5 aspect-16/10 overflow-hidden rounded-xl border border-neutral-100">
<Image
src={postImage}
alt="Thread attachment"
fill
sizes="288px"
className="object-cover"
/>
</div>
)}
 
<div className="mt-3 flex items-center gap-4">
{(
[
{
id: "like",
label: "Like",
icon: Heart,
count: likeCount,
active: liked,
onClick: () => {
setLiked(!liked);
setLikeCount(liked ? likes : likes + 1);
onLike?.();
},
},
{
id: "reply",
label: "Reply",
icon: MessageCircle,
count: replies,
},
{
id: "repost",
label: "Repost",
icon: Repeat,
count: 12,
},
{
id: "share",
label: "Share",
icon: Send,
count: null,
},
] as const
).map((action) => {
const { id, label, icon: Icon, count } = action;
const active = "active" in action ? action.active : false;
const onClick =
"onClick" in action ? action.onClick : undefined;
 
return (
<button
key={id}
type="button"
aria-label={label}
aria-pressed={id === "like" ? active : undefined}
onClick={onClick}
className="flex cursor-pointer items-center gap-1 text-neutral-500 transition-colors hover:text-neutral-900"
>
<Icon
size={14}
className={active ? "fill-rose-500 text-rose-500" : ""}
fill={active ? "rose-500" : "white"}
/>
{count !== null && (
<span className="text-[11px] font-medium tabular-nums">
{count}
</span>
)}
</button>
);
})}
</div>
</div>
</div>
</div>
);
},
);
 
ThreadsPostCard.displayName = "ThreadsPostCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/facebook/threads-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.