HTMLView

The HTML View widget renders a string of HTML content inside your app. It’s useful when you want to display rich text content that comes from a server, CMS, or external source in HTML format, without manually building UI with multiple Text widgets.

Use Cases

The HTML View widget is used to render HTML content (like <p>, <h1>, <a>, <img>, <ul>, etc.) directly inside your app.

Use HTML View when you want to:

  • Display content from the web or CMS

    • Blog posts, landing page sections, marketing content

    • Help center articles, FAQs, privacy policy, terms & conditions

  • Render pre-built HTML snippets

    • Email templates, notification templates, or CMS blocks

    • Embedded descriptions from third-party tools or dashboards

  • Show rich formatted user/admin content

    • Descriptions, announcements, or banners stored as HTML in your backend

    • Legacy content that already exists in HTML (no need to convert to Markdown or rich text manually)

  • Preview HTML-based layouts

    • Quick preview of newsletters, web copy, or small HTML fragments inside the app

Core Concepts

The HTML View widget:

  • Takes a raw HTML string from the content property.

  • Parses it into a styled widget tree.

  • Renders it as readable, formatted text inside your app.

  • Allows you to override styles for specific tags like <body>, <span>, and <p> using style override properties.

This is ideal when:

  • Your backend or CMS returns HTML.

  • You need to show “About”, “Terms & Conditions”, “Help”, or “Blog-like” content in the app.

  • You don’t want to manually convert HTML into multiple UI components.

Properties

Property
Description

content

The string of HTML content to be rendered. This can include basic tags like <p>, <span>, <b>, etc.

shrinkWrap

If true, the widget will shrink to fit its content instead of expanding to fill available space. Useful when placing it inside lists or other scrollable areas.

Style Overrides

You can provide style overrides for specific HTML tags. The available properties for each tag are similar to the TextStyle properties.

Property
Description

htmlStyleOverridesBody

Style overrides for the <body> tag.

htmlStyleOverridesSpan

Style overrides for <span> tags.

htmlStyleOverridesParagraph

Style overrides for <p> tags.

Default Properties

The HTML View widget supports the following section of Default Properties:

Layout

  • width

  • height

  • padding

  • margin

  • align

Last updated