TabBar

Icon bar where the active tab grows to reveal its label and its icon pops. Arrow keys move between tabs and badges bounce in. Navigation.

Open playground

About

TabBar 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 { TabBar } from "@ashutoshswamy/smoui" and set items, value, onChange among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<TabBar
  items={[
    { id: "home", label: "Home", icon: <HomeIcon /> },
    { id: "inbox", label: "Inbox", icon: <EnvelopeIcon /> },
  ]}
  onChange={setTab}
/>

Props 4

items

Tabs. Icons use currentColor. A badge shows a count (9+ past nine) or a plain mark on tabs that are not active.

{ id: string; label: string; icon: ReactNode; badge?: number | boolean }[]
value / defaultValue

Active id, controlled or initial. Defaults to the first.

string
onChange

Called on change, including arrow-key moves.

(id: string) => void
label

Accessible name of the bar.

stringdefault "Tabs"