Skip to content
NativeScript Unified

App structure

SplitView

<SplitView> is NativeScript core's split layout: a sidebar beside a detail column, as in a tablet's mail or settings app. It is a native view, so an HTML-first app keeps using it on a device. On iOS it is a UISplitViewController, which shows its columns side by side on a wide screen and collapses them into one column on a phone. On Android it is a plain container.

Each child sets splitRole to say which column it fills:

AttributeOnMeaning
splitRolechildprimary, supplementary, secondary or inspector
preferredPrimaryColumnWidthFractionSplitViewThe primary column's share of the width, from 0 to 1
preferredSupplementaryColumnWidthFraction, preferredInspectorColumnWidthFractionSplitViewThe same for those columns, on iOS
displayModeSplitViewHow the columns sit, on iOS: automatic, secondaryOnly, oneBesideSecondary, oneOverSecondary, twoBesideSecondary, twoOverSecondary or twoDisplaceSecondary
splitBehaviorSplitViewautomatic, tile, overlay or displace, on iOS

From code, showPrimary() and hidePrimary() open and close the primary column, and each other role has the same pair.

On the web

A browser has no split view controller, so the web-polyfills package draws <SplitView> as a CSS grid with one column per role present, in the order primary, supplementary, secondary, inspector. It reads splitRole (or split-role) and preferredPrimaryColumnWidthFraction. With no roles at all, it puts primary beside secondary, and children without a role fill columns by their position.

primary
secondary
primary
supplementary
secondary

In the native app on Android, these demos show only one column, because SplitView is a plain container there.

In an HTML page, write the grid directly. With two roles and a 0.3 primary fraction, that is a two-column grid:

primary
secondary