Skip to content
NativeScript Unified

NativeScript views

Polyfill limitations

packages/web-polyfills exists so NativeScript markup renders in a browser. It is a fallback, not a port of NativeScript.

Not custom elements

The components are Angular components whose selector is the NativeScript tag. A custom element name must contain a hyphen, so customElements.define('StackLayout') would throw and is never called. provideNsElements() and defineNsElements() are no-ops kept for compatibility.

You must import the component where you use the tag. NS_ELEMENTS is a map from tag name to component, and this site passes all of its values to every demo.

Tags that do not exist

  • Button and TextField. See Button and TextField.
  • Page and Frame, which are not registered.
  • Anything not in the NS_ELEMENTS map.

ns-tab, ns-page and ns-segmented-bar-item are plain child elements that their parent reads. They are not components.

Reduced behaviour

ViewLimit
LabelTakes text and projected content only.
SpanStyles only font-weight and color.
ListView, RepeaterShow items as plain text. No item templates.
PagerOne page visible at a time, with Prev, Next and dots. No scroll snapping.
ImageRenders nothing when src is empty.
WebViewAn iframe. A src containing < is treated as an HTML string and set as the frame document.
HtmlViewBinds the string through [innerHTML], so Angular's sanitizer applies.

Events

Angular outputs and model inputs carry plain values, for example checkedChange emits a boolean. They are not DOM CustomEvent objects. The tap-like outputs are NavigationButton tap and ListView itemTap.

Platform looks are approximations

ActionBar, Tabs, Pager and Drawer take platform="ios" or platform="material". The web cannot run UIKit or Material components, so these are CSS approximations of how the native views look. See Navigation views.

Layout attributes

  • A bare number is pixels.
  • Values outside the documented lists are ignored.
  • The polyfill writes styles onto the host and its children and re-applies them with a MutationObserver. Because those are inline styles, they win over a class that sets the same property.

Placeholder

<Placeholder> shows a dashed box saying "No native view yet" until a child is projected. It marks the spots where a real native view has no web equivalent:

No native view yet

Scope

The polyfills let NativeScript markup render in a browser. New UI belongs in Components.