NK

Search

Search pages, posts, and components

All components

Pill Tabs

Navigation

A pill tab bar where the raised pill slides to your selection.

Installation

Add it with the shadcn CLI:

$pnpm dlx shadcn@latest add https://nawalkattel.com.np/r/pill-tabs.json
Or install manually
  1. 1. Install dependencies

    pnpm add motion clsx tailwind-merge
  2. 2. Copy the component source into components/library/pill-tabs.tsx

Props

PropTypeDefaultDescription
tabsstring[] - Tab labels, in order.
activenumber0Initially active index.
onChange(index: number) => void - Called with the new index.

Accessibility

  • role=tablist / role=tab with aria-selected on the active tab.
  • The active tab changes colour as well as gaining the pill.
  • layoutId animates the pill without re-rendering the labels.

Dependencies

motionclsxtailwind-merge