Mobile › Navigation

NavBar

The bar at the top of a screen, in seven styles: standard, center, large, medium, search, transparent and modal. Large titles fold into the bar as you scroll.

Installation

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

Usage

import { Screen, NavBar, NavBarButton } from "plankui-mobile";

<Screen
  header={
    <NavBar
      title="Places"
      variant="large"
      onBack={() => router.back()}
      backLabel="Trips"
      right={<NavBarButton icon="plus" accessibilityLabel="Add place" onPress={add} />}
    />
  }
>
  {/* content */}
</Screen>

iOS and Android

iOS: Centred 17 pt title, a chevron with the previous title, a hairline that appears once content scrolls under. Large titles are 34 pt bold.

Android: Material 3 top app bar: a left-aligned title, an arrow back button, 64 dp tall. Medium and large bars show a bigger title underneath that folds into the bar on scroll.

API reference

PropTypeDefaultDescription
titlestringScreen title.
subtitlestring–A second line under the title.
variant"standard" | "center" | "large" | "medium" | "search" | "transparent" | "modal""standard"Bar style. Large and medium titles collapse on scroll; transparent fills in.
onBack() => void–Shows a back button.
backLabelstring"Back"iOS shows the previous screen's name next to the chevron.
leftReactNode–Leading buttons after the back button. Use NavBarButton.
rightReactNode–Trailing buttons. Keep it to one to three.
accessoryReactNode–Pinned under the bar, such as a SegmentedControl.
search{ value; onChangeText; placeholder? }–For variant="search": the field under the large title.
groupedbooleanfalseMatch a Screen with grouped set.

NavBarButton

PropTypeDefaultDescription
iconGlyphName | (color: string) => ReactNode–A built-in glyph or your own icon in the colour given.
labelstring–Text button, such as Cancel or Done.
onPress() => voidCalled on tap.
prominentbooleanfalseBold on iOS (Done), filled on Android (Save).
disabledbooleanfalseDims and blocks taps.
accessibilityLabelstring–Needed for icon-only buttons.