Home

Awesome

Build Status Downloads

HTML Label Plugin for Xamarin.Forms

Use this Xamarin.Forms plugin to display HTML content into a label.

Setup

How it works

On iOS and Android it uses the native HTML rendering capabilities of iOS's UILabel and Android's TextView.

UWP's TextBlock cannot renders HTML so the library parses the HTML and uses Inlines to display: <a>, <b>, <br>, <em>, <i>, <p>, <strong>, <u>, <ul> <li>, <div>.

FontAttributes, FontFamily, FontSize, TextColor, HorizontalTextAlignment are converted into inline CSS in a wrapping <div> for iOS and Android. UWP supports them natively.

Custom styling

If you need to customize something in Android or iOS you can use inline CSS, for example:

<span style="color: green">...</span>

For underlined text use the <u> tag: <u>Some underlined text</u>

For links: remember to add the schema (http:// https:// tel:// mailto:// ext...)

WARNING: not all styles are supported by each platform!

Supported Properties

Events

Navigating Navigated

Usage XAML

xmlns:htmlLabel="clr-namespace:LabelHtml.Forms.Plugin.Abstractions;assembly=HtmlLabel.Forms.Plugin"
<htmlLabel:HtmlLabel Text="{Binding HtmlString}"/>

Usage C#

var label = new HtmlLabel();
label.Text = "..htmlstring.."

Links

It is possible to customize links:

Browser options are applied with the following schemas: http, https, mailto, tel, sms and geo.

WARNING: This project uses Xamarin.Essentials to provide native Email, Phone Dial, SMS and Maps support. Please check the getting started page.

iOS WARNING: Changing the style of iOS links is not supported by iOS intentionally and this plugin use a workaround. From Apple:

To promote consistency, the intended behavior is for ranges that represent links (specified via NSLinkAttributeName) to be drawn using the default link appearance.

UWP WARNING: The minimum target for UWP is 17763. If set to an older version, it won't find the assembly.

Android's Legacy Mode

Settings the property AndroidLegacyMode to True the renderer separates block-level elements with blank lines.

Limitations

Contributions

Contributions are welcome!

License

Under MIT, see LICENSE file.