7.2.54 • Published 7 days ago

@nativescript-community/ui-material-bottomnavigationbar v7.2.54

Weekly downloads
153
License
Apache-2.0
Repository
github
Last release
7 days ago

NativeScript Material Bottom navigation bar

Material Design's Bottom navigation component for NativeScript.

npm npm

Contents

  1. Installation
  2. Changelog
  3. FAQ
  4. Usage
  5. API

Installation

For NativeScript 7.0+

  • tns plugin add @nativescript-community/ui-material-bottomnavigationbar

For NativeScript 6.x

  • tns plugin add nativescript-material-bottomnavigationbar

Be sure to run a new build after adding plugins to avoid any issues.

Changelog

FAQ

Usage

Before start using the plugin you need to add the icons for Android & iOS in your App_Resources directory.

Plain NativeScript

You can set the tabs using the tabs property

<Page xmlns="http://schemas.nativescript.org/tns.xsd"
      xmlns:mdc="@nativescript-community/ui-material-bottomnavigationbar"
      loaded="pageLoaded"
      class="page">
    <GridLayout rows="*, auto">
        <StackLayout row="0">
            <Label text="content"></Label>
        </StackLayout>
        <mdc:BottomNavigationBar
          tabs="{{ tabs }}"
          activeColor="green"
          inactiveColor="red"
          backgroundColor="black"
          tabSelected="tabSelected"
          row="1"
        ></mdc:BottomNavigationBar>
    </GridLayout>
</Page>
import { EventData } from '@nativescript/core/data/observable';
import { Page } from '@nativescript/core/ui/page';
import { BottomNavigationTab, TabSelectedEventData } from '@nativescript-community/ui-material-bottomnavigationbar';

// Event handler for Page 'loaded' event attached in main-page.xml
export function pageLoaded(args: EventData) {
    // Get the event sender
    let page = <Page>args.object;
    page.bindingContext = {
        tabs: [
            new BottomNavigationTab({ title: 'First', icon: 'res://ic_home' }),
            new BottomNavigationTab({
                title: 'Second',
                icon: 'res://ic_view_list',
                isSelectable: false
            }),
            new BottomNavigationTab({ title: 'Third', icon: 'res://ic_menu' })
        ]
    };
}

export function tabSelected(args: TabSelectedEventData) {
    console.log('tab selected ' + args.newIndex);
}

or you can add the tabs directly in your xml view

<Page xmlns="http://schemas.nativescript.org/tns.xsd"
      xmlns:mdc="@nativescript-community/ui-material-bottomnavigationbar"
      loaded="pageLoaded"
      class="page">
    <GridLayout rows="*, auto">
        <StackLayout row="0">
            <Label text="content"></Label>
        </StackLayout>
        <mdc:BottomNavigationBar
          activeColor="green"
          inactiveColor="red"
          backgroundColor="black"
          tabSelected="tabSelected"
          row="1"
        >
          <mdc:BottomNavigationTab title="First" icon="res://ic_home" />
          <mdc:BottomNavigationTab title="Second" icon="res://ic_view_list" isSelectable="false" />
          <mdc:BottomNavigationTab title="Third" icon="res://ic_menu" />
        </mdc:BottomNavigationBar>
    </GridLayout>
</Page>

Angular

First you need to include the NativeScriptMaterialBottomNavigationBarModule in your app.module.ts

import { NativeScriptMaterialBottomNavigationBarModule} from "@nativescript-community/ui-material-bottomnavigationbar/angular";

@NgModule({
    imports: [
        NativeScriptMaterialBottomNavigationBarModule
    ],
    ...
})
<GridLayout rows="*, auto">
    <StackLayout row="0">
        <label text="content"></label>
    </StackLayout>
    <BottomNavigationBar
        [tabs]="tabs"
        activeColor="red"
        inactiveColor="yellow"
        backgroundColor="black"
        (tabSelected)="onBottomNavigationTabSelected($event)"
        (tabPressed)="onBottomNavigationTabPressed($event)"
        row="1"
    ></BottomNavigationBar>
</GridLayout>

or you can declare the BottomNavigationTab in your html directly

<GridLayout rows="*, auto">
    <StackLayout row="0">
        <label text="content"></label>
    </StackLayout>
    <BottomNavigationBar
        activeColor="red"
        inactiveColor="yellow"
        backgroundColor="black"
        (tabSelected)="onBottomNavigationTabSelected($event)"
        (tabPressed)="onBottomNavigationTabPressed($event)"
        row="1"
    >
        <BottomNavigationTab title="First" icon="res://ic_home"></BottomNavigationTab>
        <BottomNavigationTab title="Second" icon="res://ic_view_list" [isSelectable]="false"></BottomNavigationTab>
        <BottomNavigationTab title="Third" icon="res://ic_menu"></BottomNavigationTab>
    </BottomNavigationBar>
</GridLayout>

Vue

If you want to use this plugin with Vue, do this in your app.js or main.js:

import BottomNavigationBar from '@nativescript-community/ui-material-bottomnavigationbar/vue';

Vue.use(BottomNavigationBar);

This will install and register BottomNavigationBar and BottomNavigationTab components to your Vue instance and now you can use the plugin as follows:

<GridLayout rows="*, auto">
    <StackLayout row="0">
        <label text="content"></label>
    </StackLayout>
    <MDBottomNavigationBar activeColor="red" inactiveColor="yellow" backgroundColor="black" @tabSelected="onBottomNavigationTabSelected" row="1">
        <MDBottomNavigationTab title="First" icon="ic_home" />
        <MDBottomNavigationTab title="Second" icon="ic_view_list" isSelectable="false" />
        <MDBottomNavigationTab title="Third" icon="ic_menu" />
    </MDBottomNavigationBar>
</GridLayout>

You can find more information of how to use nativescript plugins with Vue Here!

CSS Styling

You can also use your css file to set or change the activeColor, inactiveColor & backgroundColor of the Bottom Navigation Bar.

.botom-nav {
    active-color: green;
    inactive-color: black;
    background-color: blue;
}

API

  • Properties (bindable): Properties settable through XML/HTML
  • Properties (internal): Properties accessible through JS/TS instance
  • Events: Event properties settable thew XML/HTML

Bottom Navigation Bar

Properties (bindable)

Properties settable through XML/HTML

PropertyRequiredDefaultTypeDescription
tabstrue[]Array<BottomNavigationTab>Array containing the tabs for the BottomNavigationBar
titleVisibilityfalseTitleVisibility.SelectedTitleVisibilityTitle Visibility for each BottomNavigationTab
activeColorfalse"black"StringColor of the BottomNavigationTab when it's selected
inactiveColorfalse"gray"StringColor of the BottomNavigationTab when it's not selected
backgroundColorfalse"white"StringColor of the BottomNavigation background
badgeColorfalse"red"StringColor of the BottomNavigationTab badge background
badgeTextColorfalse"white"StringColor of the BottomNavigationTab badge text

Properties (internal)

Properties accessible through JS/TS instance

PropertyDefaultTypeDescription
items[]Array<BottomNavigationTab>Array containing the tabs for the BottomNavigationBar
selectedTabIndex0NumberIndex of the selected tab
titleVisibilityTitleVisibility.SelectedTitleVisibilityTitle Visibility for each BottomNavigationTab
activeColornew Color('black')ColorColor of the BottomNavigationTab when it's selected
inactiveColornew Color('gray')ColorColor of the BottomNavigationTab when it's not selected
backgroundColornew Color('white')ColorColor of the BottomNavigation background
badgeColornew Color('red')ColorColor of the BottomNavigationTab badge background
badgeTextColornew Color('white')ColorColor of the BottomNavigationTab badge text

Events

Event properties settable thew XML/HTML

NameTypeDescription
tabPressed(args: TabPressedEventData): voidFunction fired every time the user tap a tab with isSelectable: false
tabSelected(args: TabSelectedEventData): voidFunction fired every time the user select a new tab
tabReselected(args: TabReselectedEventData): voidFunction fired every time the user select a tab that is already selected

Methods

Methods accessible through JS/TS instance

PropertyTypeDescription
selectTab(index: number)voidSelect a tab programmatically
showBadge(index: number, value?: number)voidShow a badge for an specific tab, if you want to show a badge as a red dot no value should be passed to the function

Bottom Navigation Tab

Properties (bindable)

Properties settable through XML/HTML

PropertyRequiredDefaultTypeDescription
titletruenullstringTitle of the tab
icontruenullstringIcon of the tab
isSelectablefalsetruebooleanDetermine if the tab can be selected or not
7.2.54

7 days ago

7.2.53

19 days ago

7.2.52

19 days ago

7.2.50

22 days ago

7.2.48

1 month ago

7.2.49

1 month ago

7.2.46

2 months ago

7.2.47

2 months ago

7.2.45

3 months ago

7.2.44

3 months ago

7.2.43

4 months ago

7.2.42

4 months ago

7.2.41

4 months ago

7.2.40

4 months ago

7.2.38

4 months ago

7.2.35

4 months ago

7.2.36

4 months ago

7.2.34

4 months ago

7.2.32

4 months ago

7.2.30

4 months ago

7.2.29

4 months ago

7.2.28

5 months ago

7.2.27

5 months ago

7.2.26

5 months ago

7.2.25

5 months ago

7.2.24

5 months ago

7.2.23

5 months ago

7.2.22

6 months ago

7.2.13

6 months ago

7.2.12

6 months ago

7.2.15

6 months ago

7.2.14

6 months ago

7.2.11

6 months ago

7.2.17

6 months ago

7.2.16

6 months ago

7.2.19

6 months ago

7.2.18

6 months ago

7.2.20

6 months ago

7.2.21

6 months ago

7.1.4

10 months ago

7.2.6

6 months ago

7.2.5

6 months ago

7.2.4

7 months ago

7.2.3

7 months ago

7.2.9

6 months ago

7.2.8

6 months ago

7.2.7

6 months ago

7.2.1

7 months ago

7.2.0

7 months ago

7.1.3

1 year ago

7.1.2

1 year ago

7.1.1

1 year ago

7.1.0

1 year ago

7.0.39

1 year ago

7.0.37

1 year ago

7.0.41

1 year ago

7.0.42

1 year ago

7.0.40

1 year ago

7.0.34

1 year ago

7.0.35

1 year ago

7.0.32

1 year ago

7.0.33

1 year ago

7.0.36

1 year ago

7.0.30

2 years ago

7.0.31

1 year ago

7.0.29

2 years ago

7.0.27

2 years ago

7.0.28

2 years ago

7.0.26

2 years ago

7.0.19

2 years ago

7.0.23

2 years ago

7.0.24

2 years ago

7.0.21

2 years ago

7.0.22

2 years ago

7.0.20

2 years ago

7.0.25

2 years ago

7.0.8

2 years ago

7.0.7

2 years ago

7.0.6

2 years ago

7.0.5

2 years ago

7.0.9

2 years ago

7.0.12

2 years ago

7.0.13

2 years ago

7.0.10

2 years ago

7.0.11

2 years ago

7.0.18

2 years ago

7.0.16

2 years ago

7.0.17

2 years ago

7.0.14

2 years ago

7.0.15

2 years ago

7.0.4

2 years ago

7.0.3

2 years ago

6.2.20

2 years ago

6.2.21

2 years ago

6.2.24

2 years ago

6.2.23

2 years ago

6.2.17

2 years ago

6.2.18

2 years ago

6.2.15

2 years ago

6.2.16

2 years ago

6.2.19

2 years ago

7.0.0

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

6.2.10

2 years ago

6.2.13

2 years ago

6.2.14

2 years ago

6.2.11

2 years ago

6.2.12

2 years ago

6.2.7

2 years ago

6.2.6

2 years ago

6.2.9

2 years ago

6.2.8

2 years ago

6.2.14-alpha.0

2 years ago

6.2.14-alpha.1

2 years ago

6.2.5

2 years ago

6.2.4

2 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.1

3 years ago

6.1.2

3 years ago

6.1.1

3 years ago

6.2.0

3 years ago

6.1.0

3 years ago

6.0.6

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.3.21

3 years ago

5.3.20

3 years ago

5.3.19

3 years ago

5.3.18

3 years ago

5.3.17

3 years ago

5.3.16

3 years ago

5.3.15

3 years ago

5.3.14

3 years ago

5.3.13

3 years ago

5.3.12

3 years ago

5.3.11

3 years ago

5.3.10

3 years ago

5.3.9

3 years ago

5.3.8

3 years ago

5.3.7

3 years ago

5.3.6

3 years ago

5.3.5

3 years ago

5.3.4

3 years ago

5.4.0-alpha.4

3 years ago

5.3.3

3 years ago

5.3.2

3 years ago

5.3.0

3 years ago

5.2.31

3 years ago

5.2.30

3 years ago

5.2.29

3 years ago

5.2.28

3 years ago

5.2.27

3 years ago

5.2.26

3 years ago

5.2.25

3 years ago

5.2.24

3 years ago

5.2.23

3 years ago

5.2.22

3 years ago

5.2.21

3 years ago

5.2.20

3 years ago

5.2.19

3 years ago

5.2.18

3 years ago

5.2.17

3 years ago

5.2.16

3 years ago

5.2.15

3 years ago

5.2.14

3 years ago

5.2.13

3 years ago

5.2.12

3 years ago

5.2.11

3 years ago

5.2.10

3 years ago

5.2.9

3 years ago

5.2.8

3 years ago

5.2.7

3 years ago

5.2.5

3 years ago

5.2.3

3 years ago

5.2.2

3 years ago

5.2.1

3 years ago

5.2.0

3 years ago

5.1.16

3 years ago

5.1.15

3 years ago

5.1.14

3 years ago

5.1.12

3 years ago

5.1.10

3 years ago

5.1.9

3 years ago

5.1.8

3 years ago

5.1.7

3 years ago

5.1.6

3 years ago

5.1.5

3 years ago

5.1.4

4 years ago

5.1.3

4 years ago

5.1.1

4 years ago

5.0.30

4 years ago

5.0.29

4 years ago

5.0.28

4 years ago

5.0.26

4 years ago

5.0.27

4 years ago

5.0.24

4 years ago

5.0.25

4 years ago

5.0.23

4 years ago

5.0.22

4 years ago

5.0.21

4 years ago

5.0.17

4 years ago

5.0.18

4 years ago

5.0.19

4 years ago

5.0.20

4 years ago

5.0.16

4 years ago

5.0.14

4 years ago

5.0.12

4 years ago

5.0.13

4 years ago

5.0.11

4 years ago

5.0.10

4 years ago

5.0.9

4 years ago

5.0.8

4 years ago

5.0.7

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.0.11

4 years ago

4.0.10

4 years ago

4.0.9

4 years ago

4.0.8

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.2.20

4 years ago