Nav & tabs

Navigation link lists built from Nav, NavItem, and NavLink — styled as base links, bordered tabs, or filled pills — plus a stateful Tabs component that switches panels.

Import

tsx
import { Nav, NavItem, NavLink, Tabs, Tab } from '@metatoy/bootstrap-styled';

Base nav

NavLink takes active and disabled and is polymorphic via as (render it as a router link while keeping the styling).

Tabs & pills

Set variant="tabs" for bordered tabs or variant="pills" for filled active pills.

Fill & justify

fill grows items proportional to their content; justified makes every item exactly equal width.

Interactive tabs

The Tabs component renders a tablist plus the active panel and manages the selection. Each child Tab takes an eventKey, a title, and optional disabled; use defaultActiveKey (uncontrolled) or activeKey + onSelect (controlled).

Props

PropTypeDefaultDescription
variant"tabs" | "pills"Style variant → Bootstrap `.nav-tabs` (bordered tabs) / `.nav-pills` (filled active pill).
fillboolean`.nav-fill` — items grow to fill the width, proportional to their content.
justifiedboolean`.nav-justified` — items grow to fill the width, all equal.
asReact.ElementType
PropTypeDefaultDescription
activeboolean
disabledboolean
asReact.ElementType

Tabs

PropTypeDefaultDescription
activeKeystringControlled active key.
defaultActiveKeystringUncontrolled initial active key.
onSelect(key: string) => void
childrenReact.ReactNode

Tab

PropTypeDefaultDescription
eventKeystring
titleReact.ReactNode
disabledboolean
childrenReact.ReactNode

NavItem is a styled <li> and accepts native list-item attributes. Tab is a marker component — it renders nothing on its own; Tabs reads its props.

Theming

Nav and NavLink read the Bootstrap --bs-nav-link-* tokens (--bs-nav-link-color, --bs-nav-link-hover-color, --bs-nav-link-disabled-color, --bs-nav-link-padding-x/y). Tabs use --bs-border-color and --bs-body-bg for the active-tab border/fill; pills use the theme’s link and primary colors. These are the same custom properties the Navbar cascades into, so link theming stays consistent between the two.

Accessibility

The Tabs component renders role="tablist", role="tab" with aria-selected, and role="tabpanel", and skips disabled tabs. For a plain Nav used as site navigation, wrap it in a <nav> landmark and mark the current NavLink with active. Disabled NavLinks render as non-interactive.

Open in Ladle

Nav · Ladle · Tabs · Ladle