Docs

Main site

Installation Browser support Extend config MCP server
Validation Page speed testing Responsive design
Accordion Aspect Ratio Avatar Badge Banner Bento Grid Blockquote Breadcrumbs Button Callout Card Drawer Dropdown Link Modal Navbar Navblock Pagination Popover Progress Separator Tabs Timeline Toast Tooltip
Checkbox Datepicker File upload Form field Input Label OTP Radio Range Select Textarea Toggle
Header Footer
Accordion Auth Checkbox & Radio Content Drawers Features Modals Statistics & Metrics Teams Dropdowns
Address Contact number Currency symbol Date Emirates ID Name
Close
Home Documentation Components Tooltip

Tooltip

A Tooltip is a small, non-interactive label that appears next to a control on hover or focus to clarify its purpose. Use it for icon-button labels, abbreviations, and short hints — anything the user can take or leave. For interactive content or longer descriptions, use a Popover instead.

Overlay
Status
Active
Introduced
4.0.x
View source code

Anatomy

aegov-tooltip wraps a trigger element (its default slot) and renders a role="tooltip" panel next to it — positioned on the requested side with a small directional arrow. The panel always stays in the DOM (hidden via visibility), so it can be resolved by assistive technology through aria-describedby at any time, not only while visually shown.

Image showing anatomy of a tooltip

Item Name Description
1 Trigger The default-slot element the user hovers, focuses, or clicks
2 Panel The role="tooltip" container holding the content text or tooltip-content slot
3 Arrow Points back at the trigger; repositions itself per position/align

Basics

Wrap any trigger element in the default slot and supply content as plain text. By default the tooltip shows on hover — and always on keyboard focus, since it must remain reachable without a mouse — above the trigger (position="top").

Print
<aegov-tooltip content="Print the current page">
  <aegov-button variant="secondary" aria-label="Print">Print</aegov-button>
</aegov-tooltip>

Position

position sets which side of the trigger the tooltip appears on — top (default), right, bottom, or left. Unlike aegov-popover, the tooltip does not auto-flip to the opposite side; it stays on the requested side and is only nudged inward if it would overflow the viewport edge. position is mirrored automatically in RTL.

Top Right Bottom Left
<aegov-tooltip content="Tooltip on top" position="top">
  <aegov-button variant="secondary">Top</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Tooltip on right" position="right">
  <aegov-button variant="secondary">Right</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Tooltip on bottom" position="bottom">
  <aegov-button variant="secondary">Bottom</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Tooltip on left" position="left">
  <aegov-button variant="secondary">Left</aegov-button>
</aegov-tooltip>

Alignment

When the tooltip is positioned top or bottom, align shifts it horizontally relative to the trigger. When it's left or right, alignment shifts it vertically. Use start to anchor to the leading edge, center (default), or end to anchor to the trailing edge. align="start"/"end" flip automatically in RTL.

Start Centre End
<aegov-tooltip content="Aligned to start" position="bottom" align="start">
  <aegov-button variant="secondary">Start</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Aligned to centre" position="bottom" align="center">
  <aegov-button variant="secondary">Centre</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Aligned to end" position="bottom" align="end">
  <aegov-button variant="secondary">End</aegov-button>
</aegov-tooltip>

Trigger

By default (trigger="hover") the tooltip shows on mouse hover — and always on keyboard focus, regardless of this setting, so the tooltip is never mouse-only. Set trigger="click" to instead toggle the tooltip on click; it then closes on an outside click or Escape. Click triggers suit touch devices, where hover doesn't exist.

Hover (default) Click to open
<aegov-tooltip content="Shows on hover or keyboard focus." trigger="hover" position="top">
  <aegov-button variant="secondary">Hover (default)</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Click to toggle. Closes on outside click or Escape." trigger="click" position="top">
  <aegov-button variant="secondary">Click to open</aegov-button>
</aegov-tooltip>

Delay

delay-start (default 200ms) controls how long the pointer must hover before the tooltip appears — avoiding a flash of tooltip on every incidental mouse pass. delay-end (default 0ms) adds a brief pause before hiding, giving the pointer time to move onto the tooltip panel itself (the panel stays open while hovered).

Default delay Slow start (600ms) Slow end (400ms)
<aegov-tooltip content="Default 200ms hover delay." delay-start="200" position="top">
  <aegov-button variant="secondary">Default delay</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Appears after 600ms of sustained hover." delay-start="600" position="top">
  <aegov-button variant="secondary">Slow start (600ms)</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Lingers for 400ms after you leave." delay-end="400" position="top">
  <aegov-button variant="secondary">Slow end (400ms)</aegov-button>
</aegov-tooltip>

Gap and offset

gap (pixels, default 8) controls the distance between the trigger and the tooltip. offset (default 0) shifts the tooltip along its alignment axis — useful when the trigger has visual padding the tooltip shouldn't appear to overlap.

Tight (gap 2) Loose (gap 20) Offset (40)
<aegov-tooltip content="Snug to the trigger — only 2px gap." gap="2" position="top">
  <aegov-button variant="secondary">Tight (gap 2)</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="A larger 20px gap from the trigger." gap="20" position="top">
  <aegov-button variant="secondary">Loose (gap 20)</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="Shifted 40px along the alignment axis." gap="10" offset="40" position="top">
  <aegov-button variant="secondary">Offset (40)</aegov-button>
</aegov-tooltip>

Rich content with the slot

For content beyond plain text — emphasis, inline icons, multiple lines — provide a tooltip-content slot instead of content. The slot takes precedence when both are present. Keep tooltip content short and non-interactive; a tooltip is not focusable, so anything a user needs to click belongs in aegov-popover instead.

Status Last updated: 2 minutes ago
<aegov-tooltip position="top">
  <aegov-button variant="secondary">Status</aegov-button>
  <span slot="tooltip-content">
    <strong>Last updated:</strong> 2 minutes ago
  </span>
</aegov-tooltip>

Disabled

Set is-disabled="true" to suppress the tooltip without removing the trigger from the DOM or tab order. Useful when the extra context a tooltip provides is conditionally unavailable but the trigger itself should stay interactive.

Enabled Tooltip suppressed
<aegov-tooltip content="This tooltip opens normally." position="top">
  <aegov-button variant="secondary">Enabled</aegov-button>
</aegov-tooltip>

<aegov-tooltip content="You will not see this." is-disabled="true" position="top">
  <aegov-button variant="secondary">Tooltip suppressed</aegov-button>
</aegov-tooltip>

Composite example — Form helper text

A common pattern: pair an input label with an info icon that reveals additional guidance on hover or focus. A tooltip keeps the form short while still giving the user the detail they need, without the overhead of a focus-trapping popover.

<div class="max-w-md">
  <div class="flex items-center gap-2 mb-2">
    <label for="trade-licence" class="font-semibold">Trade licence number</label>
    <aegov-tooltip content="Your 6- to 8-digit licence number is printed on the top right of your DED licence document." position="top" align="start">
      <aegov-button is-icon appearance="soft" size="xs" aria-label="What is this?">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><path d="M12 16v-4M12 8h.01"></path></svg>
      </aegov-button>
    </aegov-tooltip>
  </div>
  <aegov-input field-id="trade-licence" placeholder="e.g. 123456"></aegov-input>
</div>

RTL support

The tooltip is direction-aware. Under dir="rtl", position="left"/"right" swap so the visual relationship to the trigger is preserved, and align="start"/"end" flip to follow the reading direction — both confirmed live. position="top"/"bottom" and align="center" are unaffected.

طباعة مساعدة تنزيل
<div dir="rtl">
  <aegov-tooltip content="طباعة الصفحة الحالية" position="top">
    <aegov-button variant="secondary">طباعة</aegov-button>
  </aegov-tooltip>

  <aegov-tooltip content="عرض المساعدة" position="left">
    <aegov-button variant="secondary">مساعدة</aegov-button>
  </aegov-tooltip>

  <aegov-tooltip content="تنزيل المستند" position="right">
    <aegov-button variant="secondary">تنزيل</aegov-button>
  </aegov-tooltip>
</div>

Usage

Here is the recommended usage of a tooltip on any website or application. These are recommended usage guides, however the developer must use the best practices of web and application development to accurately use this component.

Give the trigger its own accessible name
A tooltip describes a control — it does not name it. An icon-only button needs a real aria-label; the tooltip then supplements that label, it does not replace it.

Keep tooltip content to one short sentence
A tooltip is meant to be read in a glance. For anything longer, or content the user needs to interact with, use aegov-popover instead.

Provide an alternative on touch devices for essential content
Hover does not exist on touch. If a tooltip's content is essential rather than a bonus hint, pair it with trigger="click", a visible info icon, or persistent helper text.

Don't place interactive controls inside tooltip content
Tooltips are not focusable, so links, buttons, or form fields inside tooltip-content cannot be reached with the keyboard. Use aegov-popover or aegov-dropdown when users need to interact with the content.

Don't set aria-describedby on the trigger yourself
aegov-tooltip manages this automatically, reaching inside a shadow-DOM trigger like aegov-button to find the real focusable element. Setting it yourself risks overwriting the component's own linkage.

Don't rely on a tooltip as the only place critical information appears
Anything the user must see to complete a task should also be visible without hovering or focusing a trigger — a permanent label, hint text, or inline instruction.

API reference

The following are the properties and references of a tooltip

Properties

AttributeDescriptionTypeDefault

content

Plain-text tooltip body. Ignored when the tooltip-content slot has content.

string

undefined

position

Side of the trigger the tooltip appears on. Does not auto-flip — only clamped inward at the viewport edge. Mirrored automatically in RTL (left/right swap).

top | right | bottom | left

'top'

align

Alignment along the tooltip's cross-axis relative to the trigger. Flips in RTL.

start | center | end

'center'

trigger

How the tooltip is shown. Keyboard focus always shows the tooltip regardless of this setting.

hover | click

'hover'

gap

Distance in pixels between the trigger and the tooltip.

number

8

offset

Additional offset along the alignment axis, in pixels.

number

0

is-disabled

Suppresses the tooltip without removing the trigger from the DOM or tab order.

boolean

false

delay-start

Delay before showing on hover, in milliseconds.

number

200

delay-end

Delay before hiding on hover, in milliseconds.

number

0

Slots

SlotDescription

(default)

The trigger element — typically a button or link.

tooltip-content

Rich tooltip body. Takes precedence over the content property when present.

Pass-through attributes

Attribute groupForwarded?Notes

aria-*, data-*

Yes

Applied to the inner trigger wrapper (.aegov-tooltip-trigger), not the slotted trigger element itself.

aria-describedby

Managed

Set permanently on the trigger's real focusable element at component mount (reaching inside a shadow-DOM trigger like aegov-button automatically) and removed when the component disconnects. Do not set this yourself.

class, style

Allowed

Applied to the host element.

Notes

The following notes are applicable of this component.

Built-in accessibility

  • The tooltip panel renders with role="tooltip" and a stable id, and always stays in the DOM (hidden via visibility: hidden) rather than being added/removed — so it can be resolved by assistive technology through aria-describedby at any time.
  • aria-describedby is set permanently on the trigger's real focusable element at component mount — reaching inside a shadow-DOM trigger like aegov-button automatically (confirmed live: it lands on the inner native <button>, not just the wrapper) — and removed only when the component disconnects.
  • The tooltip appears on keyboard focus regardless of trigger mode, so it is never reachable by mouse alone.
  • Escape hides the tooltip immediately, even when it was shown purely by hover with no keyboard focus inside it (the listener is document-scoped for this reason) — SC 1.4.13 Dismissible.
  • The tooltip stays open when the pointer moves from the trigger onto the panel itself, so the content can be read or copied — SC 1.4.13 hoverable.
  • An unrecognised position, align, or trigger value falls back to its documented default.

Developer responsibilities

  • The trigger must have its own accessible name. A tooltip describes a control — it does not name it. Buttons and links should already be labelled (visible text or aria-label); the tooltip then supplements that label, not replaces it.
  • Keep tooltip content short — one short sentence at most. For richer help text, use aegov-popover.
  • Avoid placing interactive controls (links, buttons, form fields) inside tooltip content. Tooltips are not focusable and content inside them cannot be reached with the keyboard.
  • On touch devices, hover does not exist. Provide an alternative pattern (a click-triggered tooltip, an info icon next to the field, or persistent helper text) for any tooltip whose content is essential.
  • Do not set aria-describedby yourself — the component manages it automatically.

Keyboard support

Key Action
Tab Move focus to the trigger; the tooltip appears on focus regardless of trigger mode.
Enter, Space Toggle the tooltip when trigger="click" and the trigger is a button.
Escape Hide the tooltip if it is currently visible.
Shift + Tab Move focus to the previous focusable element; the tooltip hides as focus leaves.

Notes

  • The tooltip does not auto-flip to the opposite side when space is tight (unlike aegov-popover) — it only nudges inward to stay within the viewport. Choose a position that has room to render in your layout.
  • The tooltip does not emit custom events. To react to visibility changes, observe the trigger's own focus/hover state from application code.