Skip to content

docs: HtmlView #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions content/ui/htmlview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
title: HtmlView
---
<!-- TODO: Add flavors -->
`<HtmlView>` is a UI component that lets you show static HTML content.

See also: [WebView](#/ui/webview).

---
<div>
<div class="flex flex-wrap p-4 sm:p-8">
<div class="w-full sm:w-1/2">
<img src="https://raw.githubusercontent.com/nativescript-vue/nativescript-vue-ui-tests/master/screenshots/android23/HtmlView.png" alt="Android HtmlView Example"/>
</div>

<div class="w-full sm:w-1/2 sm:pl-8">
<img alt="iOS HtmlView Example" src="https://raw.githubusercontent.com/nativescript-vue/nativescript-vue-ui-tests/master/screenshots/ios-simulator103iPhone6/HtmlView.png" />
</div>
</div>
</div>

<!-- /// flavor plain -->

```xml
<HtmlView loaded="onHtmlLoaded" />
```

```ts
import { HtmlView } from '@nativescript/core'

export function onHtmlLoaded(args) {
const myHtmlView = args.object as HtmlView
myHtmlView.html = `<span>
<h1><font color=\"blue\">NativeScript HtmlView</font></h1></br>
<h3>This component accept simple HTML strings</h3></span>`
}
```
<!--
///

/// flavor angular

```html
<HtmlView [html]="htmlString"></HtmlView>
```

```ts
import { Component } from '@angular/core'

@Component({
moduleId: module.id,
templateUrl: './usage.component.html'
})
export class HtmlViewUsageComponent {
htmlString: string

constructor() {
this.htmlString = `<span>
<h1>HtmlView demo in <font color="blue">NativeScript</font> App</h1>
</span>`
}
}
```

///

/// flavor vue

```html
<HtmlView html="<div><h1>HtmlView</h1></div>" />
```

///

/// flavor react

```tsx
<htmlView html="<div><h1>HtmlView</h1></div>" />
```

///

/// flavor svelte

```html
<htmlView html="<div><h1>HtmlView</h1></div>" />
```

/// -->

## Props
### html
```xml
<HtmlView html="{{ html }}" />
```
```ts
export class HelloWorldModel extends Observable {
html = `<span>
<h1><font color=\"blue\">NativeScript HtmlView</font></h1></br>
<h3>This component accept simple HTML strings</h3></span>`
}
```
The HTML content to be shown.

---
### selectable
```xml
<HtmlView html="{{ html }}" selectable="false"/>
```
```ts
htmlView.selectable = false
```
Gets or sets a value indicating whether HtmlView is selectable.

---
### Inherited
For additional inherited properties, refer to the [API Reference](https://docs.nativescript.org/api-reference/classes/htmlview).

## Native component

| Android | iOS |
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [`android.widget.TextView`](https://developer.android.com/reference/android/widget/TextView.html) | [`UITextView`](https://developer.apple.com/documentation/uikit/uitextview) |