📺 "One project. One language. Three apps." Learn more in our upcoming code sharing webinar!

NativeScript Core

Html View

The HtmlView control represents a view with HTML content. Use this component when you want to show static HTML content. For more advanced scenarios and for dynamic content use WebView.

Basics

The HtmlView module is imported fron tns-core-modules/html-view;

const HtmlView = require("tns-core-modules/ui/html-view").HtmlView;
import { HtmlView } from "tns-core-modules/ui/html-view";

Creating a HtmlView in XML.

<HtmlView html="{{ htmlString }}"></HtmlView>

Creating a HtmlView element via code-behind files.

const myHtmlView = new HtmlView();
myHtmlView.html = "<span><h1><font color=\"blue\">NativeScript HtmlView</font></h1></br><h3>This component accept simple HTML strings</h3></span>";
const myHtmlView = new HtmlView();

myHtmlView.html = `<span>
    <h1><font color=\"blue\">NativeScript HtmlView</font></h1></br>
    <h3>This component accept simple HTML strings</h3>
</span>`;

Note: The HtmlView component has limited styling capabilities. For more complex scenarios use the WebView component.

Improve this document

Demo Source


API Reference for the HtmlView Class

Native Component

Android iOS
android.widget.TextView UILabel