Skip to the content
Konstruktor UI

Feedback and overlays

Tooltip

A few words that name or explain a control, shown on hover and on keyboard focus. The CSS .kui-tooltip shows it without a script; <kui-tooltip> adds Escape to hide it and keeps it on screen, as WCAG 1.4.13 asks.

<kui-tooltip> needs kui.js; the markup works without it as described below

Examples

On icon buttons

When the tooltip is the button’s only name, point at it with aria-labelledby. Hover a button, or Tab to it; press Escape to hide the tip.

HTML
<div class="kui-cluster kui-gap-2" role="toolbar" aria-label="Invoice actions">
  <kui-tooltip class="kui-tooltip">
    <button class="kui-button kui-button--icon kui-button--ghost" type="button" aria-labelledby="tooltip-edit"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#pencil"></use></svg></button>
    <span class="kui-tooltip__tip" role="tooltip" id="tooltip-edit">Edit</span>
  </kui-tooltip>
  <kui-tooltip class="kui-tooltip">
    <button class="kui-button kui-button--icon kui-button--ghost" type="button" aria-labelledby="tooltip-copy"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#copy"></use></svg></button>
    <span class="kui-tooltip__tip" role="tooltip" id="tooltip-copy">Duplicate</span>
  </kui-tooltip>
  <kui-tooltip class="kui-tooltip">
    <button class="kui-button kui-button--icon kui-button--ghost" type="button" aria-labelledby="tooltip-print"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#printer"></use></svg></button>
    <span class="kui-tooltip__tip" role="tooltip" id="tooltip-print">Print</span>
  </kui-tooltip>
  <kui-tooltip class="kui-tooltip">
    <button class="kui-button kui-button--icon kui-button--ghost" type="button" aria-labelledby="tooltip-delete"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#trash"></use></svg></button>
    <span class="kui-tooltip__tip" role="tooltip" id="tooltip-delete">Delete</span>
  </kui-tooltip>
</div>

Above and below, and a description

The tip is above by default; .kui-tooltip--below puts it under the control, for a toolbar at the top of the screen. When the control already has a name, the tooltip adds to it through aria-describedby.

Sync now Nobody can change invoices of October 2026 after this. Porez na dodatu vrednost, 20 %
HTML
<kui-tooltip class="kui-tooltip kui-tooltip--below">
  <button class="kui-button kui-button--icon" type="button" aria-labelledby="tooltip-sync"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#refresh-cw"></use></svg></button>
  <span class="kui-tooltip__tip" role="tooltip" id="tooltip-sync">Sync now</span>
</kui-tooltip>
<kui-tooltip class="kui-tooltip">
  <button class="kui-button" type="button" aria-describedby="tooltip-lock"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#lock"></use></svg><span>Lock period</span></button>
  <span class="kui-tooltip__tip" role="tooltip" id="tooltip-lock">Nobody can change invoices of October 2026 after this.</span>
</kui-tooltip>
<kui-tooltip class="kui-tooltip kui-tooltip--below">
  <button class="kui-button kui-button--ghost" type="button" aria-describedby="tooltip-pdv">PDV</button>
  <span class="kui-tooltip__tip" role="tooltip" id="tooltip-pdv">Porez na dodatu vrednost, 20 %</span>
</kui-tooltip>

Classes and attributes

.kui-tooltip
The wrapper of the control and its tip. Works alone with CSS on hover and focus.
<kui-tooltip class="kui-tooltip">
Adds Escape and the shift that keeps the tip inside the screen.
.kui-tooltip__tip
The tip. Give it role="tooltip" and an id.
.kui-tooltip--below
The tip under the control instead of above.
aria-labelledby or aria-describedby
On the control, pointing at the tip: labelledby when the tip is its name, describedby when it adds to a name.

Keyboard

Tab
Focus on the control shows its tip at once.
Escape
Hides the tip without moving focus or the pointer.

Accessibility

  • Follows the WAI-ARIA tooltip pattern. The tip never takes focus and holds no links or buttons.
  • It shows after a short delay on hover and at once on focus, stays while the pointer is over the control, and hides on Escape (WCAG 1.4.13).
  • Touch screens have no hover. Anything a tooltip says must not be needed to use the product; an icon-only button still has its name.
  • The tip has the strongest text colour as its background, so it keeps contrast in both modes.

Do and do not

Do

  • Name an icon-only button: “Print”.
  • Keep it to a few words, one line if possible.

Do not

  • Do not put a tooltip on a disabled button: it cannot take focus. Say why it is disabled in text nearby.
  • Do not put important instructions in a tooltip; write them in the page.