Skip to Content
zjkm-ui
Components

Pill Navbar

A navbar with a pill that slides to the active link.

Props
<PillNavbar links={links} current={pathname} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/pill-navbar.json
import { PillNavbar } from "@/components/pill-navbar"

Using JavaScript? Set tsx: false in components.json and the CLI converts it.

New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.

Usage

A rounded navbar with a pill that slides to the active link and resizes to fit it. Pass onNavigate to hand clicks to your router.

import { PillNavbar } from "@/components/pill-navbar";
import { usePathname } from "next/navigation";

export function Tabs() {
  return <PillNavbar links={[{ label: "Overview", href: "/" }, { label: "Billing", href: "/billing" }]} current={usePathname()} />;
}

Props

PropTypeDefaultDescription
links{ label, href }[]The links.
currentstringThe active link's href.
onNavigate(href, event) => voidCalled on click. Call event.preventDefault() to route yourself.
labelstring"Main"Accessible name.
classNamestringClasses for the root element.

With reduced motion, the pill jumps instead of sliding.

On this page