Skip to content
IzzyBlazor 0.1.0-alpha.17

Enter all results ↑ ↓ move Esc close

Tooltip

Text on hover and keyboard focus.

A static page with IzzyBlazor's script. No circuit.

Usage

razor
<Tooltip Text="Copy to clipboard">
    <IconButton Icon="Lucide.Copy" Label="Copy" />
</Tooltip>

@* Below the trigger, with a shortcut. *@
<Tooltip Placement="Placement.Bottom">
    <Content>Save <Kbd Keys="Ctrl+S" /></Content>
    <ChildContent><Button>Save</Button></ChildContent>
</Tooltip>

A tooltip is a short hint about a control, shown on hover and on keyboard focus: what an icon does, or its shortcut. For a panel people click to open, with links or a form, use a Popover.

Placement

Use Placement to show the tooltip below, before or after its trigger; it's above by default.

Preview

Saved to your drafts Opens in a new tab Back to the inbox On to the next message

Code

Sides.razor
<Row Gap="3" Wrap Justify="Justify.Center" PaddingY="10">
    <Tooltip Text="Saved to your drafts">
        <Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral">Top</Button>
    </Tooltip>
    <Tooltip Text="Opens in a new tab" Placement="Placement.Bottom">
        <Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral">Bottom</Button>
    </Tooltip>
    <Tooltip Text="Back to the inbox" Placement="Placement.Start">
        <Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral">Start</Button>
    </Tooltip>
    <Tooltip Text="On to the next message" Placement="Placement.End">
        <Button Variant="ButtonVariant.Outline" Accent="Accent.Neutral">End</Button>
    </Tooltip>
</Row>

With the script, when there's no room on that side, such as above a button at the top of the window, it shows on the opposite side; with JavaScript off it keeps its side.

Icon buttons and shortcuts

Use Content for more than plain text, such as a keyboard shortcut in a Kbd, and Delay for how long a hover waits (300 milliseconds; keyboard focus shows it at once).

Preview

Bold Ctrl+B Italic Ctrl+I Insert link Ctrl+K 3 unread

Code

IconButtons.razor
<Row Gap="1" Align="Align.Center" PaddingTop="10">
    <Tooltip>
        <Content>Bold <Kbd Keys="Ctrl+B" /></Content>
        <ChildContent><IconButton Icon="Lucide.Bold" Label="Bold" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" /></ChildContent>
    </Tooltip>
    <Tooltip>
        <Content>Italic <Kbd Keys="Ctrl+I" /></Content>
        <ChildContent><IconButton Icon="Lucide.Italic" Label="Italic" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" /></ChildContent>
    </Tooltip>
    <Tooltip>
        <Content>Insert link <Kbd Keys="Ctrl+K" /></Content>
        <ChildContent><IconButton Icon="Lucide.Link" Label="Insert link" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" /></ChildContent>
    </Tooltip>
    <Tooltip Text="3 unread" Delay="0">
        <IconButton Icon="Lucide.Bell" Label="Notifications" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" />
    </Tooltip>
</Row>

Static: The script links it to its button with aria-describedby and moves it to the top layer, where nothing can clip it. Escape hides it.

Inside a tooltip, an IconButton leaves out its own title, so hovering shows one tooltip, not two; it still needs its Label.

Mode support

What works in each mode, Tooltip
FeatureOffStaticLive
Shows on hover and keyboard focus, on the side Placement picksYesYesYes
Heard by screen readers as the trigger's descriptionNoYesYes
Escape hides itNoYesYes
In the top layer, where nothing clips itNoYesYes

Off: JavaScript disabled. Static: a static SSR page with IzzyBlazor's script. Live: an interactive page (Server, WebAssembly or Auto).

Accessibility

  • It's a tooltip the script links to the first focusable element inside with aria-describedby, unless that element's aria-label already says the same.
  • It shows at once on keyboard focus, after Delay on hover, and Escape hides it.
  • The trigger must be focusable, such as a button or link; text alone can't be reached from the keyboard.
  • It describes, it doesn't name: an icon-only button still needs its own Label.
  • Never put essential content in it: touch screens can't hover, and it can't hold links or buttons.
  • With JavaScript off, it shows on hover and focus, but screen readers don't hear it and Escape doesn't hide it.

Parameters

Tooltip parameters
PropTypeDefault
TextThe tooltip text.string?
ContentTooltip content in place of Text.RenderFragment?
PlacementWhere it appears.PlacementPlacement.Top
DelayMilliseconds of hover before it appears.int300
ChildContentThe element the tooltip describes, usually a button or link.RenderFragment?

See also

  • Popover: non-modal content beside a trigger.
  • IconButton: a square button with a required label.
  • Button: submits, resets, links or runs C#.