Pill Nav Header
An app header with centred pill tabs and an active state, in separate or tray style, with an actions slot. Tabs scroll on mobile.
npx shadcn@latest add https://ui.develop-better-solutions.com/r/pill-nav-header.jsonUsage
pill-nav-header-example.tsx
"use client";
import { useState } from "react";
import { Bell, Settings } from "lucide-react";
import { PillNavHeader } from "@dbs/ui";
const NAV = ["Dashboard", "Patient", "Appointment", "Report"];
export default function PillNavHeaderExample() {
const [active, setActive] = useState("Dashboard");
const btn = "flex h-[46px] w-[46px] items-center justify-center rounded-full bg-surface";
return (
<div className="w-full">
<PillNavHeader
sticky={false}
logo={<span className="text-xl font-semibold">Careline</span>}
items={NAV.map((n) => ({ label: n, href: "#", active: n === active }))}
linkComponent={(props: Record<string, unknown>) => {
const { href: _h, children, ...rest } = props as { href: string; children: React.ReactNode } & Record<string, unknown>;
return (
<a
{...rest}
href="#"
onClick={(e) => {
e.preventDefault();
if (typeof children === "string") setActive(children);
}}
>
{children}
</a>
);
}}
>
<button type="button" aria-label="Settings" className={btn}><Settings className="h-5 w-5" strokeWidth={1.8} /></button>
<button type="button" aria-label="Notifications" className={btn}><Bell className="h-5 w-5" strokeWidth={1.8} /></button>
</PillNavHeader>
</div>
);
}