Getting Started
In this tutorial, you will learn how to make your own tooltip component in Blazor. We will also see how to use the Blazor MarkupString with the tooltip.
Create the Tooltip Component
In the folder pages, Add a new component namely Tooltip.razor.
Step 2:
In the Tooltip component, add the following html code for the tooltip wrapper:
<div class="tooltip-wrapper">
<span id="spanText">@((MarkupString)Text)</span>
@ChildContent
</div>
Step 3:
Then we will add the following CSS script:
In the @code block we will the the following parameters:
[Parameter] public string Text { get; set; }
Reusable Tooltip Component
You can now use the tooltip component by adding the below in the pages you want it to be displayed
The tooltip text will display This is a tooltip on hovering on Your Text.
It will be bold as the MarkupString will convert the <b> </b> tags to html instead of rendering it as text.
Make sure to watch the video tutorial below as I have explained MarkupString and how to use the tooltip in more details.
Post a Comment
Post a Comment