opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Twitter
  4. Twitter Profile
Back to Twitter

Components / Twitter

Twitter Profile

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

Twitter/X profile with cover, avatar, bio, location, website link, and follower counts. Follow button included.

Preview

Profile cover image
Profile avatar

Bidyut Kundu

@bidyutkundu

Building things on the web · Minimalism enthusiast · Open-source

West Bengalopensourceui.in
320 Following1.2K Followers

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/twitter/twitter-profile-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { TwitterProfileCard } from "@/components/twitter/twitter-profile-card";

    <TwitterProfileCard />

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/twitter/twitter-profile-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
"use client";
 
import {
forwardRef,
type ComponentPropsWithoutRef,
type ReactNode,
} from "react";
import Image from "next/image";
 
import { cn } from "@/lib/cn";
 
import { MapPin, Globe } from "lucide-react";
 
export type TwitterProfileCardProps = Readonly<
{
name?: string;
username?: string;
bio?: string;
location?: string;
website?: string;
following?: string | number;
followers?: string | number;
coverImage?: string;
avatar?: string;
coverImageAlt?: string;
avatarAlt?: string;
followLabel?: string;
locationIcon?: ReactNode;
websiteIcon?: ReactNode;
followButton?: ReactNode;
onFollow?: () => void;
} & ComponentPropsWithoutRef<"div">
>;
 
// Production-ready Twitter Profile component — styled with Tailwind CSS.
export const TwitterProfileCard = forwardRef<
HTMLDivElement,
TwitterProfileCardProps
>(
(
{
className,
name = "Bidyut Kundu",
username = "@bidyutkundu",
bio = "Building things on the web · Minimalism enthusiast · Open-source",
location = "West Bengal",
website = "opensourceui.in",
following = 320,
followers = "1.2K",
coverImage = "/wallpaper-3.png",
avatar = "/profile-picture.png",
coverImageAlt = "Profile cover image",
avatarAlt = "Profile avatar",
followLabel = "Follow",
locationIcon,
websiteIcon,
followButton,
onFollow,
...props
},
ref,
) => {
return (
<div
ref={ref}
data-slot="twitter-profile-card"
className={cn(
"w-72 overflow-hidden rounded-2xl border border-neutral-100 bg-white font-sans shadow-lg",
className,
)}
{...props}
>
{/* Cover image */}
<div data-slot="twitter-profile-card-cover" className="relative h-24">
<Image
src={coverImage}
alt={coverImageAlt}
fill
className="object-cover"
sizes="288px"
/>
 
{/* Profile avatar */}
<div className="absolute -bottom-8 left-5 flex h-16 w-16 items-center justify-center rounded-full border-4 border-white bg-neutral-800">
<Image
src={avatar}
alt={avatarAlt}
width={28}
height={28}
className="w-7"
sizes="28px"
/>
</div>
</div>
 
<div
data-slot="twitter-profile-card-content"
className="px-5 pt-12 pb-5"
>
<div className="flex items-start justify-between">
<div>
<p
title={name}
className="text-lg leading-none font-semibold text-neutral-900"
>
{name}
</p>
 
<p title={username} className="mt-1 text-sm text-neutral-400">
{username}
</p>
</div>
 
{followButton ?? (
<button
type="button"
aria-label={`Follow ${name}`}
onClick={onFollow}
className="cursor-pointer rounded-full bg-neutral-800 px-3 pt-1 pb-0.5 text-[10px] font-medium text-white transition-colors hover:bg-black"
>
{followLabel}
</button>
)}
</div>
 
{/* Bio */}
<p
data-slot="twitter-profile-card-bio"
title={bio}
className="mt-4 text-sm leading-relaxed text-neutral-700"
>
{bio}
</p>
 
{/* Profile details */}
<div
data-slot="twitter-profile-card-details"
className="mt-4 flex flex-wrap gap-4 text-sm text-neutral-500"
>
<span className="flex items-center gap-1">
{locationIcon ?? <MapPin size={13} />}
{location}
</span>
 
<span className="flex items-center gap-1">
{websiteIcon ?? <Globe size={13} />}
{website}
</span>
</div>
 
{/* Stats */}
<div
data-slot="twitter-profile-card-stats"
className="mt-4 flex gap-5 text-sm text-neutral-500"
>
<span>
<b className="text-neutral-900">
{typeof following === "number"
? following.toLocaleString()
: following}
</b>{" "}
Following
</span>
 
<span>
<b className="text-neutral-900">
{typeof followers === "number"
? followers.toLocaleString()
: followers}
</b>{" "}
Followers
</span>
</div>
</div>
</div>
);
},
);
 
TwitterProfileCard.displayName = "TwitterProfileCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/twitter/twitter-profile-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.