How it works
A soft cover band tinted from a stable hue derived from the name, an avatar overlapping it inside a surface-coloured ring, a tight name and role, stats split by hairlines and the follow button. Pressing Follow flips the button and any stat marked follows at once; if the Promise from onFollowChange rejects, both roll back and a short error appears. The two button faces share one grid cell, so the width never jumps; the check draws in; and right after following, hovering does not offer Unfollow until the pointer has left once.
Use it for
- Author, creator or teammate cards in feeds, directories and sidebars.
- Any follow, subscribe or connect action that should feel instant.
Look elsewhere when
- Actions that must be confirmed by the server before showing success, such as payments.
- Full profile pages: use a page layout.
Usage
import { ProfileCard } from './ProfileCard.jsx'
export function AuthorCard({ author }) {
return (
<ProfileCard
name={author.name}
role={author.role}
avatar={author.photoUrl}
status="online"
defaultFollowing={author.isFollowed}
stats={[
{ label: 'Projects', value: author.projects },
{ label: 'Followers', value: author.followers, follows: true },
]}
// Return a Promise: a rejection rolls the button and the count back
onFollowChange={(next) => api.setFollow(author.id, next)}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
name | string | — | Display name; also gives the initials and the avatar hue. |
role | ReactNode | — | One line under the name. |
avatar | string | — | Image URL; without it the initials show on a gradient. |
status | 'online' | 'busy' | 'away' | — | Presence dot on the avatar. |
stats | Array<{ label, value, format?, follows? }> | [] | Figures in a row. follows: true moves that number by one with the button. |
following | boolean | — | Controlled state. |
defaultFollowing | boolean | false | Initial state when uncontrolled. |
onFollowChange | (next: boolean) => void | Promise | — | Called with the new state; the card has already flipped. A rejected Promise rolls back and shows labels.error. |
actions | ReactNode | — | Extra buttons beside Follow. |
layout | 'vertical' | 'horizontal' | 'vertical' | Centred with cover, or avatar beside the name. |
cover | boolean | true | Shows the tinted cover band. |
labels | object | — | follow, following, unfollow, error, followed(name), unfollowed(name). Shallow-merged over English. |
Accessibility
- The card is an <article> with the name as an <h3>; stats are a description list.
- Follow is a native button with a constant name and aria-pressed; the visible faces are hidden from screen readers.
- Every change is announced through a polite live region, including the rollback message.
- The button is 44px tall; focus-visible shows a ring outside a surface-colour gap.
- Reduced motion keeps only fades: no face slide, press scale or checkmark drawing.
Motion
Faces cross over in 240ms ease-out with a 6px rise; the check draws in 360ms; pressing scales to 97% for 100ms and springs back. While saving, the changed count is tinted with the accent and fades back in 360ms.
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.
ProfileCard.jsxprofile-card.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.





