Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

react-native-material-bottom-navigation

1.0.0 • Public • Published

react-native-material-bottom-navigation


npm version downloads

A beautiful, customizable and easy-to-use
Material Design Bottom Navigation for react-native.


  • Pure JavaScript. No native dependencies. No linking. No obstacles.
  • Looks beautiful. Stunning and fluid animations. You won't believe it's not a native view.
  • Customize it. You can adjust nearly everything to make it fit perfectly to your app.
  • Easy to use. Uses established React patterns for both simple and advanced usage.
  • Pluggable. Includes customizable Tabs and Badges. Not enough? Create and use your own!

Installation

Using npm:

npm install react-native-material-bottom-navigation

Or using yarn:

yarn add react-native-material-bottom-navigation

Table of Contents

Demo


Shifting Tab


Full Tab


Icon Tab

Usage

This library uses "render props" as simple technique for component composition. The example below shows the basic usage of the Bottom Navigation. All available Props are listed in the Documentation.

⚠️ Out-of-the-box support for React Navigation was removed with v1. (Read more.) You can still use an earlier version.

Also check out the example apps.

import BottomNavigation, {
  FullTab
} from 'react-native-material-bottom-navigation'
 
export default class App extends React.Component {
  tabs = [
    {
      key: 'games',
      icon: 'gamepad-variant',
      label: 'Games',
      barColor: '#388E3C',
      pressColor: 'rgba(255, 255, 255, 0.16)'
    },
    {
      key: 'movies-tv',
      icon: 'movie',
      label: 'Movies & TV',
      barColor: '#B71C1C',
      pressColor: 'rgba(255, 255, 255, 0.16)'
    },
    {
      key: 'music',
      icon: 'music-note',
      label: 'Music',
      barColor: '#E64A19',
      pressColor: 'rgba(255, 255, 255, 0.16)'
    }
  ]
 
  renderIcon = icon => ({ isActive }) => (
    <Icon size={24} color="white" name={tab.icon} />
  ))
 
  renderTab = ({ tab, isActive }) => (
    <FullTab
      isActive={isActive}
      key={tab.key}
      label={tab.label}
      renderIcon={this.renderIcon(tab.icon)}
    />
  )
 
  render() {
    return (
      <View style={{ flex: 1 }}>
        <View style={{ flex: 1 }}>
          {/* Your screen contents depending on current tab. */}
        </View>
        <BottomNavigation
          onTabPress={activeTab => this.setState({ activeTab })}
          renderTab={this.renderTab}
          tabs={this.tabs}
        />
      </View>
    )
  }
}

Documentation

Notes

React Navigation Support

In contrary to earlier releases, this library (currently) does not support React Navigation out of the box. React Navigation now ships with an own Material Bottom Navigation: createMaterialTopTabNavigator. The API of React Navigation changes quite frequently, and (until now) it wasn't easy to always keep track and be up-to-date. Also I don't want to favor and promote React Navigation over other Navigation Libraries.

If you integrate material-bottom-navigation with a navigation library in your project, feel free to share your knowledge by opening an Issue, submitting a Pull Request or event create your own module which uses material-bottom-navigation.

Updated Material Design Specs

Google updated the Material Guidelines on Google I/O 2018 with new specifications, including the Bottom Navigation with a FAB in a centered cutout. material-bottom-navigation uses the older specs and does not support those new specs.

Contribute

Contributions are always welcome. Read more in the Contribution Guides.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Authors

Author

Contributors

See Contributors List. Thanks to everyone!

License

MIT, © 2017 - present Timo Mämecke

install

npm i react-native-material-bottom-navigation

Downloadsweekly downloads

625

version

1.0.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar