---
title: "Add a tooltip to a C# desktop button"
url: https://recursiveai.org/oneapp/cookbook/add-tool-tip-to-desktop-button/
description: "Wrap a OneApp button in a tooltip. Set a pointer delay, show the same hint on keyboard focus, and link the button to the hint by ID."
version: "1.1.1"
---

Wrap the button in `Tooltip` and set `DelayMs` for hover. OneApp runs on [Linux, Windows, and macOS on Apple silicon](https://github.com/recursive-ai-oss/oneapp-csharp/blob/64b0f3162f8c1b7bb766ceae32357442feaa5960/README.md#L62-L68).

```shell
dotnet add package RecursiveAI.OneApp.Kit
dotnet add package RecursiveAI.OneApp
dotnet add package RecursiveAI.OneUI
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```html
<!-- Export: handler in ExportPage.cs. -->
<Tooltip Id="export-help" DelayMs="500"
  Text="Downloads a CSV of the current report.">
  <Button Id="export"
    AriaDescribedBy="export-help"
    OnClick="{Export}">Export report</Button>
</Tooltip>
```

[The example](https://recursiveai.org/oneapp/cookbook/add-tool-tip-to-desktop-button/add-tool-tip-to-desktop-button.zip) is the full program below: unzip it and `dotnet run`.

Hover over **Export report** for half a second, or press Tab to focus it.

## Full program

OneApp hosts the window, OneApp.Kit supplies the controls, and OneUI compiles the `.html` component.

The zip contains the three files below and `Demo.csproj`. To make the project by hand, create a .NET 10 console app and install the packages above. The example’s project references are:

```xml
<PackageReference Include="RecursiveAI.OneApp" Version="1.1.1" />
<PackageReference Include="RecursiveAI.OneApp.Kit" Version="1.1.1" />
<PackageReference Include="RecursiveAI.OneUI" Version="1.1.0" />
```

OneUI compiles `ExportPage.html` into the other half of the partial class in `ExportPage.cs`. Save these files beside the project file.

`ExportPage.html`:

```html
<Theme>
  <main style="padding: 24px">
    <h2 style="margin-bottom: 36px">Report</h2>
    <Tooltip Id="export-help" DelayMs="500"
             Text="Downloads a CSV of the current report.">
      <Button Id="export" AriaDescribedBy="export-help"
              OnClick="{Export}">Export report</Button>
    </Tooltip>
  </main>
</Theme>
```

`ExportPage.cs`:

```csharp
public partial class ExportPage
{
    private static void Export() => Console.WriteLine("Export requested (demo only).");
}
```

`Program.cs` opens the native window:

```csharp
using OneApp;

using var host = AppHost.Create(new AppOptions(new ExportPage())
{
    Title = "Export",
    Width = 420,
    Height = 205,
});
host.Run();
```

The tooltip shows this text in the window:

```text
Downloads a CSV of the current report.
```

Move the pointer away, move focus away, or press Escape while the button has focus to hide the tooltip. Activating the button prints `Export requested (demo only).` in the terminal; the example doesn’t write a CSV.

If the hint appears visually but the button has no description, check that `AriaDescribedBy` exactly matches the tooltip’s `Id`.

![Add a tooltip to a C# desktop button: example window](https://recursiveai.org/oneapp/images/add-tool-tip-to-desktop-button/window.png)

## Variations

To prefer the space below the button, add `Side` to the opening tag in `ExportPage.html`:

```html
<Tooltip Id="export-help" DelayMs="500"
  Side="{OneApp.Kit.OverlaySide.Bottom}"
  Text="Downloads a CSV of the current report.">
```

## Related recipes

- [Build a desktop app with HTML and CSS in C#](https://recursiveai.org/oneapp/cookbook/build-desktop-app-with-html-css/)
- [Customize desktop dark mode and colors](https://recursiveai.org/oneapp/cookbook/theme-desktop-ui-kit/)

## The short answer

Put the `Button` inside `Tooltip`. Set `Text` to the hint, `DelayMs` to the hover delay, and give the tooltip an `Id`. Put the same ID in the button’s `AriaDescribedBy`. That connects the hint as a description without replacing the button’s name.

## How do I display a tooltip on a button?

The button goes in the tooltip’s default slot: there’s no separate trigger declaration. In the example, **Export report** names the action and the tooltip adds the file format and which report is exported. Keep the label meaningful without the hint, and put instructions that are required to complete a task in visible text instead.

## What is the difference between a tooltip and hover?

Hover is one way to show a tooltip. It isn’t the only one: `DelayMs="500"` waits for the pointer to rest on the button, but moving keyboard focus to the button shows the hint immediately. Pressing Escape with focus on the button dismisses the hint without moving focus. Unlike a popover, the tooltip contains text, not controls the user needs to reach.
