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 playgroundAbout
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
npm i @ashutoshswamy/smouiUsage
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"
More navigation components
- BreadcrumbsA trail that folds its middle into an ellipsis. Press it and the hidden crumbs spring out in order.
- DockIcons swell around the cursor and settle back on a spring.
- FlyoutNavOne panel that follows you. Move between items and it glides sideways and resizes to the new content while the content cross-fades.
- GooMenuA plus that throws its items out as liquid bubbles and fuses them back on close.
- MorphTooltipOne tooltip for the whole toolbar. It stretches to the next tool and resizes to its label.
- PaginationOne accent pill slides to the page you pick. Long lists fold into ellipses that follow the current page.