NOTE! You are browsing legacy documentation. For latest visit docs.nativescript.org.

NativeScript Core

Html View

The HtmlView represents a view with HTML content. Use this component instead of a WebView when you want to show static HTML content with base HTML support.

Usage

<HtmlView html="{{ htmlString }}"></HtmlView>
const HtmlView = require("tns-core-modules/ui/html-view").HtmlView;
function createHtmlView() {

    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>";

    return myHtmlView;
}
import { HtmlView } from "tns-core-modules/ui/html-view";
function createHtmlView() {
    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>`;

    return myHtmlView;
}

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


Properties

Name Type Description
html string Gets or sets the HTML string. Limited HTML support - for extended support use WebView

Events

Name Description
layoutChangedEvent String value used when hooking to layoutChanged event.
loaded String value used when hooking to loaded event.

API References

Name Type API Reference Link
HtmlView Module
HtmlView Class

Native Component

Android iOS
android.widget.TextView UILabel