PillNav

Pill whose highlight stretches toward the item you pick. Navigation.

Open playground

About

PillNav is a React component in the Navigation category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { PillNav } from "@ashutoshswamy/smoui" and set items, defaultValue, onChange.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { PillNav } from "@ashutoshswamy/smoui";

<PillNav
  items={[{ id: "work", label: "Work" }, { id: "about", label: "About" }]}
  onChange={(id) => console.log(id)}
/>

Props 3

items

Nav entries.

{ id: string; label: string }[]
defaultValue

Initially active id. Defaults to the first.

string
onChange

Called when the active item changes.

(id: string) => void