Tableau UI for Angular

Tooltips

A tooltip shows a text or a template beside an element while the pointer is over it, or while the keyboard's focus is on it.

Import

Import TableauUiTooltipModule from tableau-ui-angular/tooltip.

A text

tooltip goes on any element. A tooltip opens when the pointer enters the element, or when the keyboard moves the focus to it or into it; the focus a click gives doesn't open one, a text input's included. Once the pointer leaves the element it has 100 ms to reach the tooltip, and as long as it needs while it stays between the two; the tooltip closes when the pointer moves anywhere else, or leaves the tooltip. Focus from the keyboard keeps a tooltip while the pointer passes over the element and leaves, and the tooltip closes when the focus leaves, unless the pointer is on the element or the tooltip. Escape closes it.

  • tooltipPosition is top, the default, bottom, left or right. A tooltip that would leave the window moves to the other side.
  • tooltipMargin is its distance from the element, 0.5rem by default; a number without a unit is in pixels.
  • tooltipPadding is the space inside it, 0.5rem by default; it takes a CSS padding, such as 0.5rem 1rem.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { TableauUiButtonModule } from 'tableau-ui-angular/button';
import { TableauUiTooltipModule } from 'tableau-ui-angular/tooltip';

@Component({
  selector: 'app-tooltip-text-example',
  imports: [TableauUiButtonModule, TableauUiTooltipModule],
  templateUrl: './tooltip-text.example.html',
  styleUrl: './tooltip-text.example.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TooltipTextExampleComponent {}

A template

[tooltip] takes a template too, and [tooltipContext] its context. tooltipArgsMode says where the tooltip's arguments come from:

ModeThe arguments
individual, the defaultThe inputs above, one by one
full[tooltipFullArgs], one object: the template, its context, the position, the margin and the padding
lazy[tooltipLazyArgs], a function the tooltip calls each time it would open; when it gives undefined, no tooltip opens
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { TableauUiButtonModule } from 'tableau-ui-angular/button';
import { TableauUiTooltipModule } from 'tableau-ui-angular/tooltip';

@Component({
  selector: 'app-tooltip-template-example',
  imports: [TableauUiButtonModule, TableauUiTooltipModule],
  templateUrl: './tooltip-template.example.html',
  styleUrl: './tooltip-template.example.scss',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TooltipTemplateExampleComponent {}

Accessibility

A tooltip follows the WAI-ARIA tooltip pattern: it describes its element, and never names it.

  • While it shows, its box is role="tooltip", and the element's aria-describedby names it after the app's own ids, which stay. A text tooltip equal to the element's name, as on the nav bar's collapsed buttons, adds no description, so a screen reader doesn't read it twice.
  • Tab to the element shows its tooltip. Escape hides it and goes no further, so a dialog, menu or drawer under the tooltip closes on the next Escape, and the user dismisses a tooltip without moving the pointer or the focus. A list the element opened above the tooltip, such as a select's, closes on the first Escape, and the tooltip on the next. After Escape the pointer shows the tooltip again once it has left the element.
  • The pointer can rest on a tooltip, to read it or to get past it, and crosses the margin to it at any pace. A click on a tooltip doesn't reach what is under it, so place a tooltip where it covers nothing the user reaches for next, as tooltipPosition can.
  • The app names the element. An icon-only button needs a name of its own, such as a label on its tab-icon or an aria-label, with a tooltip or without.
  • Nothing in a tooltip takes the focus, so a template holds no link or button. A touch screen has no hover, so put nothing in a tooltip that a user needs.