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-hapticsUsage
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
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | Screen title. | |
| subtitle | string | – | 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. |
| backLabel | string | "Back" | iOS shows the previous screen's name next to the chevron. |
| left | ReactNode | – | Leading buttons after the back button. Use NavBarButton. |
| right | ReactNode | – | Trailing buttons. Keep it to one to three. |
| accessory | ReactNode | – | Pinned under the bar, such as a SegmentedControl. |
| search | { value; onChangeText; placeholder? } | – | For variant="search": the field under the large title. |
| grouped | boolean | false | Match a Screen with grouped set. |
NavBarButton
| Prop | Type | Default | Description |
|---|---|---|---|
| icon | GlyphName | (color: string) => ReactNode | – | A built-in glyph or your own icon in the colour given. |
| label | string | – | Text button, such as Cancel or Done. |
| onPress | () => void | Called on tap. | |
| prominent | boolean | false | Bold on iOS (Done), filled on Android (Save). |
| disabled | boolean | false | Dims and blocks taps. |
| accessibilityLabel | string | – | Needed for icon-only buttons. |