Profile Header With Tabs
A profile card with a large avatar, follow button, stats and work, activity and about tabs.
"use client"
import { useState } from "react"
import { CalendarBlankIcon, LinkIcon, MapPinIcon } from "@phosphor-icons/react"
import { Title } from "@/components/title/title"
import { Avatar, AvatarBadge, AvatarFallback } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/components/ui/tabs"
// The copy: change text here, not in the markup.
const COPY = {
name: "Mara Okonkwo",
handle: "@mara",
title: "Design lead at Harbor",
bio: "Building calm tools for busy teams. Currently untangling onboarding and the new billing flow.",
location: "Lisbon, Portugal",
site: "mara.design",
joined: "Joined March 2022",
follow: "Follow",
following: "Following",
message: "Message",
} as const
const STATS = [
{ label: "Projects", value: "24" },
{ label: "Followers", value: "1,208" },
{ label: "Following", value: "312" },
] as const
const TABS = [
{
value: "work",
label: "Work",
body: "Onboarding redesign, Billing v2 and the Harbor mobile shell.",
},
{
value: "activity",
label: "Activity",
body: "Commented on Q4 launch plan, 4 minutes ago.",
},
{
value: "about",
label: "About",
body: "Works across design systems, research and prototyping.",
},
] as const
export default function AvatarProfileHeader() {
const [follow, setFollow] = useState(false)
return (
<div className="mx-auto w-full max-w-2xl overflow-hidden rounded-2xl border bg-card text-card-foreground">
<div className="h-24 bg-linear-to-r from-chart-1/30 via-chart-3/25 to-chart-5/30" />
<div className="px-5 pb-5">
<div className="-mt-10 flex flex-wrap items-end justify-between gap-3">
<Avatar className="size-20 ring-4 ring-card">
<AvatarFallback className="bg-chart-1/30 text-2xl font-semibold text-foreground">
MO
</AvatarFallback>
<AvatarBadge className="size-4 bg-chart-2" />
</Avatar>
<div className="flex gap-2">
<Button variant="outline" size="sm">
{COPY.message}
</Button>
<Button
size="sm"
variant={follow ? "secondary" : "default"}
onClick={() => setFollow((v) => !v)}
>
{follow ? COPY.following : COPY.follow}
</Button>
</div>
</div>
<div className="mt-3 flex flex-wrap items-center gap-2">
<Title render={<h2 />}>{COPY.name}</Title>
<Badge variant="secondary">{COPY.handle}</Badge>
</div>
<p className="text-sm text-muted-foreground">{COPY.title}</p>
<p className="mt-3 max-w-prose text-sm">{COPY.bio}</p>
<div className="mt-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground">
<span className="inline-flex items-center gap-1">
<MapPinIcon className="size-3.5" />
{COPY.location}
</span>
<span className="inline-flex items-center gap-1">
<LinkIcon className="size-3.5" />
{COPY.site}
</span>
<span className="inline-flex items-center gap-1">
<CalendarBlankIcon className="size-3.5" />
{COPY.joined}
</span>
</div>
<dl className="mt-4 flex gap-6">
{STATS.map((s) => (
<div key={s.label}>
<dt className="text-xs text-muted-foreground">{s.label}</dt>
<dd className="text-lg font-semibold tabular-nums">{s.value}</dd>
</div>
))}
</dl>
<Tabs defaultValue="work" className="mt-5">
<TabsList>
{TABS.map((t) => (
<TabsTrigger key={t.value} value={t.value}>
{t.label}
</TabsTrigger>
))}
</TabsList>
{TABS.map((t) => (
<TabsContent
key={t.value}
value={t.value}
className="pt-3 text-sm text-muted-foreground"
>
{t.body}
</TabsContent>
))}
</Tabs>
</div>
</div>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the card, panel or column that holds it is the
// measure. text-pretty keeps a wrapped title from ending on one word.
/**
* The title of a card, panel or list group, rendered as an `<h3>` in the body
* font: 18px with a 28px line, 20px from the `sm` breakpoint, medium weight.
* One size, no props beyond the element's own; pass `render` to use another
* heading level. Inside a stock `Card`, use `CardTitle`; a section's heading
* is `Subheading` and a page's headline is `Heading`.
*/
function Title({
className,
render,
...props
}: useRender.ComponentProps<"h3">) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "title" },
props: mergeProps<"h3">(
{
className: cn(
"text-lg/7 font-medium tracking-tight text-pretty sm:text-xl/7",
className
),
},
props
),
})
}
export { Title }
Installation
pnpm dlx shadcn@latest add @01orbital/profile-header-01npx shadcn@latest add @01orbital/profile-header-01yarn dlx shadcn@latest add @01orbital/profile-header-01bunx --bun shadcn@latest add @01orbital/profile-header-01Make it yours
- Its words are in
COPYat the top ofcomponents/blocks/app/profile-header-01/index.tsx: change them there, not in the markup. STATSandTABS, also at the top of the file, hold its lists and settings.
Built from
npm: @phosphor-icons/react. The CLI installs it for you.
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on