Profile card
A creator profile card with a generative cover, availability status, counting stats and a follow button that morphs into a check.
"use client";
import { useEffect, useRef, useState } from "react";
import "./profile-card.css";
type Stat = { label: string; value: number; suffix?: string };
type ProfileCardProps = {
name: string;
handle: string;
bio: string;
stats: Stat[];
skills?: string[];
available?: boolean;
theme?: "light" | "dark";
};
/** Counts from 0 to `to` once the card is on screen. */
function useCount(to: number, run: boolean) {
const [n, setN] = useState(0);
useEffect(() => {
if (!run) return;
let raf = 0;
if (matchMedia("(prefers-reduced-motion: reduce)").matches) {
raf = requestAnimationFrame(() => setN(to));
return () => cancelAnimationFrame(raf);
}
const start = performance.now();
const tick = (now: number) => {
const t = Math.min(1, (now - start) / 1200);
setN(Math.round(to * (1 - Math.pow(1 - t, 3)))); // ease-out cubic
if (t < 1) raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [to, run]);
return n;
}
function StatItem({ stat, run }: { stat: Stat; run: boolean }) {
const n = useCount(stat.value, run);
return (
<div>
<dt>{stat.label}</dt>
<dd>
{n.toLocaleString()}
{stat.suffix}
</dd>
</div>
);
}
/**
* ProfileCard
* - Stats count up the first time the card scrolls into view.
* - Follow button: "Follow" -> check + "Following"; hovering "Following" offers "Unfollow".
*/
export function ProfileCard({
name,
handle,
bio,
stats,
skills = [],
available = true,
theme = "light",
}: ProfileCardProps) {
const ref = useRef<HTMLElement>(null);
const [seen, setSeen] = useState(false);
const [following, setFollowing] = useState(false);
const initials = name
.split(" ")
.map((p) => p[0])
.join("")
.slice(0, 2);
useEffect(() => {
const el = ref.current;
if (!el) return;
const io = new IntersectionObserver(
([e]) => e.isIntersecting && (setSeen(true), io.disconnect()),
{ threshold: 0.4 },
);
io.observe(el);
return () => io.disconnect();
}, []);
return (
<article ref={ref} className="gu-profile" data-theme={theme}>
<div className="gu-profile__cover" aria-hidden="true" />
<div className="gu-profile__body">
<div className="gu-profile__top">
<span className="gu-profile__avatar" aria-hidden="true">
{initials}
</span>
<button
type="button"
className="gu-profile__follow"
aria-pressed={following}
onClick={() => setFollowing((f) => !f)}
>
<span className="gu-profile__follow-in">
{following ? (
<>
<svg viewBox="0 0 16 16" aria-hidden="true">
<path d="m3 8.5 3 3 7-7" />
</svg>
<span className="gu-profile__state">Following</span>
<span className="gu-profile__undo">Unfollow</span>
</>
) : (
"Follow"
)}
</span>
</button>
</div>
<h3>{name}</h3>
<p className="gu-profile__handle">
{handle}
{available && (
<span className="gu-profile__status">Open to work</span>
)}
</p>
<p className="gu-profile__bio">{bio}</p>
{skills.length > 0 && (
<ul className="gu-profile__skills" aria-label="Skills">
{skills.map((s) => (
<li key={s}>{s}</li>
))}
</ul>
)}
<dl className="gu-profile__stats">
{stats.map((s) => (
<StatItem key={s.label} stat={s} run={seen} />
))}
</dl>
</div>
</article>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Profile card
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A profile card for a creator or freelancer: a drifting dot-pattern cover, a rounded-square avatar overlapping it, a follow button, name, handle with an "Open to work" status dot, bio, skill chips and three stats that count up when the card appears.
## Layout and look
- Max 370px, radius 26px, 1px border, background #fbf8f2 (dark #18181b).
- Cover: 110px tall, #0e0e10 (dark #2b35ff) with two layered dot lattices (orange #ff5a1f 22px grid + smaller faint grid; lime dots in dark mode).
- Avatar: 84px, radius 28px, orange with dark initials (weight 900), 5px border in the card color, pulled up 38px over the cover.
- Follow: 42px dark pill; following = lime #d7ff3a with a check and "Following"; on hover it reads "Unfollow" on the dark pill.
- Name 23px weight 900; muted handle; green status dot with a soft ring; skill chips outlined; stats in a 3-column grid above a 1px divider, big tabular numbers on top of small muted labels.
## Behavior and motion
1. Cover background-position drifts linearly forever (18s loop).
2. Stats count from 0 with ease-out cubic over 1.2s once 40% of the card is visible (IntersectionObserver, once).
3. Follow button presses to 0.95.
## Touch
No hover needed; the Unfollow swap only happens on hover-capable devices, tapping simply toggles.
## Accessibility
- <article>, the follow button uses aria-pressed, stats are a <dl>, skills a labelled list, avatar is aria-hidden.
- prefers-reduced-motion: no drift, numbers appear final immediately.
## Props
name, handle, bio, stats ({ label, value, suffix? }[]), skills, available, theme.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### ProfileCard.tsx
```tsx
"use client";
import { useEffect, useRef, useState } from "react";
import "./profile-card.css";
type Stat = { label: string; value: number; suffix?: string };
type ProfileCardProps = {
name: string;
handle: string;
bio: string;
stats: Stat[];
skills?: string[];
available?: boolean;
theme?: "light" | "dark";
};
/** Counts from 0 to `to` once the card is on screen. */
function useCount(to: number, run: boolean) {
const [n, setN] = useState(0);
useEffect(() => {
if (!run) return;
let raf = 0;
if (matchMedia("(prefers-reduced-motion: reduce)").matches) {
raf = requestAnimationFrame(() => setN(to));
return () => cancelAnimationFrame(raf);
}
const start = performance.now();
const tick = (now: number) => {
const t = Math.min(1, (now - start) / 1200);
setN(Math.round(to * (1 - Math.pow(1 - t, 3)))); // ease-out cubic
if (t < 1) raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [to, run]);
return n;
}
function StatItem({ stat, run }: { stat: Stat; run: boolean }) {
const n = useCount(stat.value, run);
return (
<div>
<dt>{stat.label}</dt>
<dd>
{n.toLocaleString()}
{stat.suffix}
</dd>
</div>
);
}
/**
* ProfileCard
* - Stats count up the first time the card scrolls into view.
* - Follow button: "Follow" -> check + "Following"; hovering "Following" offers "Unfollow".
*/
export function ProfileCard({
name,
handle,
bio,
stats,
skills = [],
available = true,
theme = "light",
}: ProfileCardProps) {
const ref = useRef<HTMLElement>(null);
const [seen, setSeen] = useState(false);
const [following, setFollowing] = useState(false);
const initials = name
.split(" ")
.map((p) => p[0])
.join("")
.slice(0, 2);
useEffect(() => {
const el = ref.current;
if (!el) return;
const io = new IntersectionObserver(
([e]) => e.isIntersecting && (setSeen(true), io.disconnect()),
{ threshold: 0.4 },
);
io.observe(el);
return () => io.disconnect();
}, []);
return (
<article ref={ref} className="gu-profile" data-theme={theme}>
<div className="gu-profile__cover" aria-hidden="true" />
<div className="gu-profile__body">
<div className="gu-profile__top">
<span className="gu-profile__avatar" aria-hidden="true">
{initials}
</span>
<button
type="button"
className="gu-profile__follow"
aria-pressed={following}
onClick={() => setFollowing((f) => !f)}
>
<span className="gu-profile__follow-in">
{following ? (
<>
<svg viewBox="0 0 16 16" aria-hidden="true">
<path d="m3 8.5 3 3 7-7" />
</svg>
<span className="gu-profile__state">Following</span>
<span className="gu-profile__undo">Unfollow</span>
</>
) : (
"Follow"
)}
</span>
</button>
</div>
<h3>{name}</h3>
<p className="gu-profile__handle">
{handle}
{available && (
<span className="gu-profile__status">Open to work</span>
)}
</p>
<p className="gu-profile__bio">{bio}</p>
{skills.length > 0 && (
<ul className="gu-profile__skills" aria-label="Skills">
{skills.map((s) => (
<li key={s}>{s}</li>
))}
</ul>
)}
<dl className="gu-profile__stats">
{stats.map((s) => (
<StatItem key={s.label} stat={s} run={seen} />
))}
</dl>
</div>
</article>
);
}
```
### profile-card.css
```css
/* ProfileCard: change these colors to match your brand. */
.gu-profile {
--card: #fbf8f2;
--text: #0e0e10;
--muted: #57534b;
--line: rgb(14 14 16 / 0.12);
--cover: #0e0e10;
--dots: #ff5a1f;
--avatar: #ff5a1f;
--avatar-text: #0e0e10;
--btn: #0e0e10;
--btn-text: #f3eee3;
--ok: #d7ff3a;
--focus: #2b35ff;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
width: min(100%, 370px);
overflow: hidden;
border: 1px solid var(--line);
border-radius: 26px;
background: var(--card);
color: var(--text);
font-family: system-ui, sans-serif;
}
.gu-profile[data-theme="dark"] {
--card: #18181b;
--text: #f3eee3;
--muted: #aea89c;
--line: rgb(243 238 227 / 0.12);
--cover: #2b35ff;
--dots: #d7ff3a;
--btn: #f3eee3;
--btn-text: #0e0e10;
--focus: #d7ff3a;
}
/* Generative cover: a drifting dot lattice */
.gu-profile__cover {
height: 110px;
background-color: var(--cover);
background-image:
radial-gradient(var(--dots) 1.6px, transparent 1.8px),
radial-gradient(
color-mix(in srgb, var(--dots) 45%, transparent) 1px,
transparent 1.2px
);
background-size:
22px 22px,
11px 11px;
background-position:
0 0,
5px 5px;
animation: gu-profile-drift 18s linear infinite;
}
@keyframes gu-profile-drift {
to {
background-position:
220px 110px,
115px 115px;
}
}
.gu-profile__body {
padding: 0 22px 22px;
}
.gu-profile__top {
display: flex;
align-items: end;
justify-content: space-between;
margin-top: -38px;
}
.gu-profile__avatar {
display: grid;
place-items: center;
width: 84px;
height: 84px;
border: 5px solid var(--card);
border-radius: 28px;
background: var(--avatar);
color: var(--avatar-text);
font-size: 1.7rem;
font-weight: 900;
letter-spacing: -0.04em;
}
.gu-profile__follow {
min-width: 124px;
min-height: 42px;
padding: 0 18px;
border: 0;
border-radius: 999px;
background: var(--btn);
color: var(--btn-text);
font: inherit;
font-weight: 800;
font-size: 0.9rem;
cursor: pointer;
transition:
background-color 0.3s,
color 0.3s,
transform 0.2s;
}
.gu-profile__follow:active {
transform: scale(0.95);
}
.gu-profile__follow:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 3px;
}
.gu-profile__follow[aria-pressed="true"] {
background: var(--ok);
color: #0e0e10;
}
.gu-profile__follow-in {
display: inline-flex;
align-items: center;
gap: 6px;
}
.gu-profile__follow svg {
width: 15px;
height: 15px;
fill: none;
stroke: currentColor;
stroke-width: 2.2;
stroke-linecap: round;
stroke-linejoin: round;
}
.gu-profile__undo {
display: none;
}
@media (hover: hover) {
.gu-profile__follow[aria-pressed="true"]:hover {
background: var(--btn);
color: var(--btn-text);
}
.gu-profile__follow[aria-pressed="true"]:hover .gu-profile__state,
.gu-profile__follow[aria-pressed="true"]:hover svg {
display: none;
}
.gu-profile__follow[aria-pressed="true"]:hover .gu-profile__undo {
display: inline;
}
}
.gu-profile h3 {
margin: 14px 0 0;
font-size: 1.45rem;
font-weight: 900;
letter-spacing: -0.03em;
}
.gu-profile__handle {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
margin: 4px 0 0;
color: var(--muted);
font-size: 0.9rem;
}
.gu-profile__status {
display: inline-flex;
align-items: center;
gap: 6px;
color: var(--text);
font-size: 0.78rem;
font-weight: 700;
}
.gu-profile__status::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: #22c55e;
box-shadow: 0 0 0 3px rgb(34 197 94 / 0.25);
}
.gu-profile__bio {
margin: 14px 0 0;
font-size: 0.95rem;
line-height: 1.5;
}
.gu-profile__skills {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin: 14px 0 0;
padding: 0;
list-style: none;
}
.gu-profile__skills li {
padding: 5px 10px;
border: 1px solid var(--line);
border-radius: 999px;
font-size: 0.78rem;
font-weight: 600;
}
.gu-profile__stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
margin: 18px 0 0;
padding-top: 16px;
border-top: 1px solid var(--line);
}
.gu-profile__stats div {
display: flex;
flex-direction: column-reverse;
}
.gu-profile__stats dd {
margin: 0;
font-size: 1.35rem;
font-weight: 900;
font-variant-numeric: tabular-nums;
letter-spacing: -0.03em;
}
.gu-profile__stats dt {
color: var(--muted);
font-size: 0.78rem;
}
@media (prefers-reduced-motion: reduce) {
.gu-profile__cover {
animation: none;
}
}
```
You might also want
Next piece: Public roadmapStat cards with sparklines
Components, intermediate
3D tilt card
Components, intermediate
Activity rings
Components, intermediate