Navigation bar

The navigation bar component encapsulates a title and icon/text actions for controlling views.

Nav Bar

Maven Central Class reference Source code

Collapsed

Day Night
Collapsed NavBar component Collapsed NavBar component - dark mode

Expanded

Day Night
Expanded NavBar component Expanded NavBar component - dark mode
Day Night
Navigation NavBar component Navigation NavBar component - dark mode

Installation

Backpack Android is available through Maven Central. Check the main Readme for a complete installation guide.

Usage

The NavBar component can be used in both XML and Kotlin/Java

Example of a NavBar in XML


                                                
                                                <net.skyscanner.backpack.navbar.BpkNavBar
                                                  android:layout_width="match_parent"
                                                  android:layout_height="wrap_content"
                                                  app:navBarTitle="Nav Bar"
                                                  app:navBarIcon="@drawable/bpk_native_android__back"
                                                  app:navBarMenu="@menu/settings"/>

Example of a NavBar in Kotlin


                                                
                                                import net.skyscanner.backpack.navbar.BpkNavBar
                                                
                                                BpkNavBar(context).apply {
                                                  title = "Nav Bar"
                                                  menu = R.menu.settings
                                                  icon = AppCompatResources.getDrawable(context, R.drawable.bpk_native_android__back)
                                                }

The NavBar component uses the same logic as AppBarLayout, and needs to be used as a direct child of CoordinatorLayout.

The scrolling child of CoordinatorLayout should have app:layout_behavior="@string/appbar_scrolling_view_behavior" attribute.

Theme Props

Styles can be changed globally through bpkNavBarStyle. Check theming for more information.