Getting Started with Blazor Tooltip Component

8 Oct 20215 minutes to read

This section briefly explains how to include a Tooltip in the Blazor Server-Side application. Refer to the Getting Started with Syncfusion Blazor for Server-Side in Visual Studio 2019 page for the introduction and configuring the common specifications.

To get start quickly with the Blazor Tooltip, check on this video.

Importing Syncfusion Blazor component in the application

Any one of the below standards can be used to install the Syncfusion Blazor library in the application.

Using Syncfusion Blazor Individual NuGet Packages [New standard]

Starting with Volume 4, 2020 (v18.4.0.30) release, Syncfusion provides individual NuGet packages for our Syncfusion Blazor components. We highly recommend this new standard for your Blazor production applications. Refer to this section to know the benefits of the individual NuGet packages.

  1. Install Syncfusion.Blazor.Popups NuGet package to the application by using the NuGet Package Manager. Refer to the Individual NuGet Packages section for the available NuGet packages.

    Blazor NuGet Explorer

  2. Search Syncfusion.Blazor.Popups keyword in the Browse tab and install Syncfusion.Blazor.Popups NuGet package in the application.

    Searching Blazor Tooltip NuGet Package

  3. Once the installation process is completed, the Syncfusion Blazor Popups package will be installed in the project.

  4. The client-side style resources can be added through CDN or from NuGet package in the <head> element of the ~/Pages/_Host.cshtml page.

     <head>
         ....
         ....
         <link href="_content/Syncfusion.Blazor.Themes/bootstrap4.css" rel="stylesheet" />
     </head>

    WARNING

    Syncfusion.Blazor package should not be installed along with the individual NuGet packages. Hence, add the above Syncfusion.Blazor.Themes static web assets (styles) in the application.

Using Syncfusion.Blazor NuGet Package [Old standard]

WARNING

If you prefer the above new standard (individual NuGet packages), then skip this section. Using both old and new standards in the same application will throw ambiguous compilation errors.

  1. Install Syncfusion.Blazor NuGet package to the application by using the NuGet Package Manager. Right-click the project and then select Manage NuGet Packages.

    Blazor NuGet Explorer

  2. Search Syncfusion.Blazor keyword in the Browse tab and install Syncfusion.Blazor NuGet package in the application.

    Blazor NuGet Package

  3. Once the installation process is completed, the Syncfusion Blazor package will be installed in the project.

  4. The client-side style resources can be added using NuGet package to the <head> element of the ~/wwwroot/index.html page in Blazor WebAssembly app or ~/Pages/_Host.cshtml page in Blazor Server app.

<head>
    ....
    ....
    <link href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
</head>
<head>
    <link href="https://cdn.syncfusion.com/blazor/19.3.43/styles/bootstrap4.css" rel="stylesheet" />
</head>

For Internet Explorer 11 kindly refer the polyfills. Refer the documentation for more information.

<head>
    <link href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
    <script src="https://github.com/Daddoon/Blazor.Polyfill/releases/download/3.0.1/blazor.polyfill.min.js"></script>
</head>

Add Syncfusion Blazor service in Startup.cs (Server-side application)

Open the Startup.cs file and add services required by Syncfusion components using services.AddSyncfusionBlazor() method. Add this method in the ConfigureServices function as follows.

using Syncfusion.Blazor;

namespace BlazorApplication
{
    public class Startup
    {
        ....
        ....
        public void ConfigureServices(IServiceCollection services)
        {
            ....
            ....
            services.AddSyncfusionBlazor();
        }
    }
}

Add Syncfusion Blazor service in Program.cs (Client-side application)

Open the Program.cs file and add services required by Syncfusion components using builder.services.AddSyncfusionBlazor() method. Add this method in the Main function as follows.

using Syncfusion.Blazor;

namespace BlazorApplication
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            ....
            ....
            builder.Services.AddSyncfusionBlazor();
        }
    }
}

Adding component package to the application

Open ~/_Imports.razor file and import the Syncfusion.Blazor.Popups package.

@using Syncfusion.Blazor
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.Popups

Adding Tooltip component to the application

Now, add the Syncfusion Blazor Tooltip component in any web page razor in the Pages folder. For example, the Tooltip component is added in the ~/Pages/Index.razor page.

@using Syncfusion.Blazor.Popups
@using Syncfusion.Blazor.Buttons

<SfTooltip ID="Tooltip" Target="#btn" Content="@Content">
    <SfButton ID="btn" Content="Show Tooltip"></SfButton>
</SfTooltip>

@code
{
    string Content = "Lets go green & Save Earth !!";
}

Run the application

After successful compilation of your application, simply press F5 to run the application.

Blazor Tooltip

See Also