Skip to main content

TabBar

import { TabBar } from "@study/ui"

Result
Loading...
Live Editor
<div style={{ maxWidth: 390, padding: 12, background: "var(--ui-sunken)", borderRadius: 32 }}>
  <TabBar
    fixed={false}
    active="today"
    items={[
      { id: "today", label: "Today", icon: "sun", href: "#" },
      { id: "courses", label: "Courses", icon: "grid", href: "#" },
      { id: "calendar", label: "Calendar", icon: "calendar", href: "#" },
      { id: "search", label: "Search", icon: "search", href: "#" },
    ]}
    action={{ label: "Create new", icon: "plus", onClick: () => toast("New …") }}
  />
  <Toaster />
</div>

When to use​

  • Only below about 900 px width; above that the Sidebar.
  • Four places, in the middle at most one round action ("New").
  • With fixed (default) it sticks to the bottom and leaves room for the iPhone's home bar. The content above it needs about 100 px of space at the bottom.

Props​

PropTypeDefaultMeaning
items *TabBarItem[]–
action{ label: string; icon: "code" | "link" | "search" | "filter" | "image" | "sun" | "grid" | "calendar" | "checklist" | "settings" | "shield" | "home" | "plus" | "minus" | "close" | "check" | ... 52 more ... | "calculator"; onClick: () => void; }–A round button in the middle, e.g. "Create".
activestring–The id of the current place.
classNamestring–
fixedbooleantrueSticks to the bottom of the window.
labelstringuiText().mainNav
linkAsElementType–The link element, e.g. react-router's `Link` (it gets `to`).

Accessibility​

  • Every place has an icon and text; the active one is aria-current="page".
  • The round action carries its name as aria-label.