Horizontal navigation

A simple navigation component, ideal for representing a section of a page that links to other pages or views within the page.

bpk-component-horizontal-nav

Backpack React Native horizontal navigation component.

Default

Day Night
bpk-component-horizontal-nav default iPhone 8 simulator bpk-component-horizontal-nav default iPhone 8 simulator - dark mode
bpk-component-horizontal-nav default Google Pixel emulator bpk-component-horizontal-nav default Google Pixel emulator - dark mode

Small

Day Night
bpk-component-horizontal-nav small iPhone 8 simulator bpk-component-horizontal-nav small iPhone 8 simulator - dark mode
bpk-component-horizontal-nav small Google Pixel emulator bpk-component-horizontal-nav small Google Pixel emulator - dark mode

Space around

Day Night
bpk-component-horizontal-nav space-around iPhone 8 simulator bpk-component-horizontal-nav space-around iPhone 8 simulator - dark mode
bpk-component-horizontal-nav space-around Google Pixel emulator bpk-component-horizontal-nav space-around Google Pixel emulator - dark mode

Installation

Check the main Readme for a complete installation guide.

Usage


                                                
                                                import React, { Component } from 'react';
                                                import BpkHorizontalNav, { BpkHorizontalNavItem } from 'backpack-react-native/bpk-component-horizontal-nav';
                                                
                                                export default class App extends Component {
                                                  constructor() {
                                                    super();
                                                    this.state = {
                                                      selectedId: 'flights',
                                                    };
                                                  }
                                                
                                                  render() {
                                                    return (
                                                      <BpkHorizontalNav selectedId={this.state.selectedId}>
                                                        <BpkHorizontalNavItem
                                                          id="flights"
                                                          title="Flights"
                                                          onPress={() => {
                                                            this.setState({ selectedId: 'flights' });
                                                          }}
                                                        />
                                                        <BpkHorizontalNavItem
                                                          id="hotels"
                                                          title="Hotels"
                                                          onPress={() => {
                                                            this.setState({ selectedId: 'hotels' });
                                                          }}
                                                        />
                                                        <BpkHorizontalNavItem
                                                          id="car-hire"
                                                          title="Car hire"
                                                          onPress={() => {
                                                            this.setState({ selectedId: 'car-hire' });
                                                          }}
                                                        />
                                                      </BpkHorizontalNav>
                                                    );
                                                  }
                                                };

Props

BpkHorizontalNav

Property PropType Required Default Value
children node true -
selectedId string (matching id prop of BpkHorizontalNavItem child) true -
selectedIndicatorStyle style object false null
spaceAround bool false false

selectedIndicatorStyle

Styles to apply to the indicator placed below the selected nav item.

BpkHorizontalNavItem

Property PropType Required Default Value
id string true -
onPress func true -
title string true -
accessibilityLabel string false props.title
disabled bool false false
small bool false false
textStyle style object false null
theme See Theme Props below false null

textStyle

Styles to apply to the BpkText component inside the nav item.

Theme Props

BpkHorizontalNav

  • horizontalNavSelectedTextColor

BpkHorizontalNavItem

  • horizontalNavSelectedTextColor