Tooltip no longer supports HTML formatted text

I use the TooltipService to display a tooltip:

TooltipService.Open(buttonHelp.Element, "<div><b>&quot;de&quot;</b> or <b>&quot;en&quot;</b> are supported values.</div>", new TooltipOptions() { Duration = 5000 });

With the recent version of Blazor controls this seems not to work any more. The HTML is displayed as plan text. Any ideas what could be wrong?

Thanks!

Hi @JustJoe,

Indeed HTML strings are no longer supported as this was considered a security risk. Here is how to use HTML: Blazor Tooltip Component | Free UI Components by Radzen

This syntax is supported only in .razor files. If you want to use it in a C# file you need something like this:

    RenderFragment renderFragment = builder =>
    {
        builder.AddMarkupContent(0, "<strong>Some</strong> content");
    };

    void ShowTooltipWithHtml(ElementReference elementReference, TooltipOptions options = null)
    {
        tooltipService.Open(elementReference, ds => renderFragment);
    }

Ah, thanks! Good to know. However, I would recommend to update the documentation accordingly, since there is still an example that shows how to directly use HTML-formatted text...

Thanks a lot!

Is there? We should have updated the demos.

Yes, please see Class TooltipService

I believe this is the correct example as it is the one used in the online demo. It uses a Razor render fragment which is secure.