An open API service indexing awesome lists of open source software.

https://github.com/soenneker/soenneker.blazor.floating.tooltips

A modern Blazor interop library for Floating UI-powered tooltips
https://github.com/soenneker/soenneker.blazor.floating.tooltips

blazor blazorlibrary csharp dotnet floating floating-ui floatingtooltip tooltips ui

Last synced: 4 days ago
JSON representation

A modern Blazor interop library for Floating UI-powered tooltips

Awesome Lists containing this project

README

          

[![](https://img.shields.io/nuget/v/soenneker.blazor.floating.tooltips.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.floating.tooltips/)
[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.floating.tooltips/publish-package.yml?style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.floating.tooltips/actions/workflows/publish-package.yml)
[![](https://img.shields.io/nuget/dt/soenneker.blazor.floating.tooltips.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.floating.tooltips/)
[![](https://img.shields.io/badge/Demo-Live-blueviolet?style=for-the-badge&logo=github)](https://soenneker.github.io/soenneker.blazor.floating.tooltips/)
[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.floating.tooltips/codeql.yml?label=CodeQL&style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.floating.tooltips/actions/workflows/codeql.yml)

# Logo Soenneker.Blazor.Floating.Tooltips

> Modern Blazor tooltips powered by Floating UI.

`Soenneker.Blazor.Floating.Tooltips` is a Blazor component library that integrates with [Floating UI](https://floating-ui.com/) to provide position-aware, customizable, and interactive tooltips with a C# API.

[Open the demo site](https://soenneker.github.io/soenneker.blazor.floating.tooltips/)

---

## Features

- Position-aware and collision-resistant tooltip placement
- Custom placements, show/hide delays, themes, and arrows
- Interactive tooltip content
- Manual show, hide, and toggle support from C#
- Event callbacks for show and hide
- Optional CDN loading for Floating UI scripts
- Packaged static web assets for local script and stylesheet loading

---

## Installation

```bash
dotnet add package Soenneker.Blazor.Floating.Tooltips
```

Register the service:

```csharp
using Soenneker.Blazor.Floating.Tooltips.Registrars;

builder.Services.AddFloatingTooltipAsScoped();
```

Add the namespace where you use the components:

```razor
@using Soenneker.Blazor.Floating.Tooltips
@using Soenneker.Blazor.Floating.Tooltips.Enums
@using Soenneker.Blazor.Floating.Tooltips.Options
```

---

## Usage

Basic tooltip with plain text:

```razor

Hover me

```

Tooltip with options and event callbacks:

```razor

Hover over me

@code {
private void HandleShow() => Console.WriteLine("Tooltip shown");
private void HandleHide() => Console.WriteLine("Tooltip hidden");
}
```

Rich content with `TooltipContent`:

```razor



Smart Tooltip

Rich content goes here.

Hover me

```

---

## Options

You can set options through `FloatingTooltipOptions`:

```razor
@using Soenneker.Blazor.Floating.Tooltips.Enums
@using Soenneker.Blazor.Floating.Tooltips.Options

Hover me

@code {
private readonly FloatingTooltipOptions _options = new()
{
Animate = true,
ShowArrow = true,
Theme = FloatingTooltipTheme.Light,
MaxWidth = 250,
ManualTrigger = false,
UseCdn = true
};
}
```

Or set the same values inline:

```razor

Hover me

```

`UseCdn` defaults to `true`. When set to `false`, the library loads its bundled static web assets from `_content/Soenneker.Blazor.Floating.Tooltips/...`, which works with Blazor base paths such as GitHub Pages project sites.

---

## Programmatic Control

Use `@ref` to control a tooltip manually:

```razor

Toggle tooltip

@code {
private FloatingTooltip? _tooltip;

private async Task ToggleTooltip()
{
if (_tooltip is not null)
await _tooltip.Toggle();
}
}
```

Available methods:

```csharp
await tooltip.Show();
await tooltip.Hide();
await tooltip.Toggle();
```