Mobile › Navigation

TabBar

Bottom tabs for an app's three to five main sections, with optional badges.

Installation

npx expo install plankui-mobile react-native-safe-area-context expo-haptics

Usage

import { Screen, TabBar } from "plankui-mobile";

const [tab, setTab] = useState("home");

<Screen
  header={<NavBar title="Home" variant="large" />}
  footer={
    <TabBar
      value={tab}
      onChange={setTab}
      items={[
        { key: "home", label: "Home", icon: ({ color, size }) => <HomeIcon color={color} size={size} /> },
        { key: "inbox", label: "Inbox", badge: 3, icon: ({ color, size }) => <InboxIcon color={color} size={size} /> },
        { key: "me", label: "Profile", icon: ({ color, size }) => <UserIcon color={color} size={size} /> },
      ]}
    />
  }
>
  {/* content */}
</Screen>

iOS and Android

iOS: Icons with 10 pt labels over a hairline, 49 pt tall, the selected tab in the accent colour.

Android: Material 3 navigation bar, 80 dp tall, with a pill behind the selected icon.

API reference

PropTypeDefaultDescription
items{ key; label; icon: ({ focused, color, size }) => ReactNode; badge?: number | boolean }[]Three to five tabs. Draw the icon in the colour you are given.
valuestringThe selected tab's key.
onChange(key: string) => voidCalled with the tapped tab's key.