Skip to content
NativeScript Unified

App structure

Navigation views

The bar across the top of a screen, the tabs along the bottom and the drawer at the side are native views on a device. They are app structure, so an HTML-first app keeps them, and its HTML pages render inside them. On the web, the web-polyfills package draws approximations of the same tags, so a template that uses them still renders in a browser.

On a device

ViewComes fromIn the native app
ActionBar, NavigationButton, ActionItem@nativescript/core, through ActionBarComponent from @nativescript/angularRouted pages import ActionBarComponent to show their own title
BottomNavigation@nativescript-community/ui-bottom-navigationThe home screen's Guide, Components and UI tabs
Tabs@nativescript-community/ui-tabsRegistered, not used on a screen
Drawer@nativescript-community/ui-drawerWraps the app in app.component.ts. Side sheets open in it.
PagerA plugin such as @nativescript-community/ui-pagerNot installed

apps/native/src/main.ts registers the plugin views with registerElement(). The home screen, apps/native/src/app/pages/index.page.ts, is a BottomNavigation with one TabStripItem per tab and one TabContentItem per screen. Trimmed, it reads:

<ActionBar title="NativeScript Unified" />
<BottomNavigation selectedIndex="0">
  <TabStrip>
    <TabStripItem><Label text="Guide"></Label></TabStripItem>
    <TabStripItem><Label text="Components"></Label></TabStripItem>
    <TabStripItem><Label text="UI"></Label></TabStripItem>
  </TabStrip>
  <TabContentItem><guide-list kind="guide" /></TabContentItem>
  <TabContentItem><guide-list kind="components" /></TabContentItem>
  <TabContentItem><ui-demo /></TabContentItem>
</BottomNavigation>

On the web

A browser has none of these views, so the polyfills draw them with CSS. The demos below use the polyfills' own markup (ns-tab, ns-page, slots) rather than the plugins' child elements, so the native app shows their code only. ActionBar, Tabs, Pager and Drawer take platform="ios" or platform="material", which restyles them as an approximation of the native look. The default is default.

ActionBar

title is the bar title. <NavigationButton text="Back"> is the back control. Other children go in the leading or trailing slot. large turns on the iOS large title.

Inbox

Edit

Inbox

Inbox

Inbox

Inbox

Inbox

Tabs

Children are plain <ns-tab label="..."> elements. selectedIndex picks the tab, and segmented makes the iOS look a segmented control.

Pager

Children are <ns-page> elements. One shows at a time, with Prev and Next buttons and dots. There is no swipe or scroll snapping.

Page one

Drawer

The default content is the page, and slot="drawer" is the panel. open is a model, and width defaults to 280 pixels. The panel is positioned over the content, so give the drawer a height.

Tapping the scrim closes it too.

Looks per platform

On ios, Tabs becomes a bottom bar and Pager shows only dots. On material, ActionBar uses the primary colour and Drawer has rounded end corners. These are CSS approximations, as described in Polyfill limitations.

Inside a page

For tabs inside a page, use helm Tabs. For a side panel, use the Sheet, and for a bottom panel, the Drawer. packages/ui/helm also has sidebar and navigation-menu, which these pages do not cover. The web app builds its own app-level navigation, such as this site's header and sidebar. See Web vs native.