The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
import { InfoTooltip } from "@dub/ui";
import { cn } from "@dub/utils";
import { ChevronLeft } from "lucide-react";
import Link from "next/link";
import { ReactNode } from "react";
import { PageWidthWrapper } from "../page-width-wrapper";
import { NavButton } from "./nav-button";
export type PageContentHeaderProps = {
title?: ReactNode;
titleInfo?: ReactNode | { title: string; href?: string };
titleBackHref?: string;
controls?: ReactNode;
headerContent?: ReactNode;
};
export function PageContentHeader({
title,
titleInfo,
titleBackHref,
controls,
headerContent,
}: PageContentHeaderProps) {
// Generate titleInfo from object if provided
const finalTitleInfo =
titleInfo && typeof titleInfo === "object" && "title" in titleInfo ? (
<InfoTooltip
content={
titleInfo.href
? `${titleInfo.title} [Learn more](${titleInfo.href})`
: titleInfo.title
}
/>
) : (
titleInfo
);
const hasHeaderContent = !!(title || controls || headerContent);
return (
<div className={cn("border-border-subtle", hasHeaderContent && "border-b")}>
<PageWidthWrapper>
<div
className={cn(
"flex h-12 items-center justify-between gap-4",
hasHeaderContent ? "sm:h-16" : "sm:h-0",
)}
>
<div className="flex min-w-0 items-center gap-4">
<NavButton />
{title && (
<div className="flex min-w-0 items-center gap-2">
{titleBackHref && (
<Link
href={titleBackHref}
className="rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"
>
<ChevronLeft className="size-5" />
</Link>
)}
<h1 className="text-content-emphasis min-w-0 text-lg font-semibold leading-7">
{title}
</h1>
{finalTitleInfo}
</div>
)}
</div>
{controls && (
<div className="flex items-center gap-2">{controls}</div>
)}
</div>
{headerContent && <div className="pb-3 pt-1">{headerContent}</div>}
</PageWidthWrapper>
</div>
);
}