-
Notifications
You must be signed in to change notification settings - Fork 7
Tooltip
- Tooltip specification
Team Name: Astrea + Design and Web Development
Developer name: Arkan Ahmedov, Riva Ivanova
Designer name: Diana Koleva, Dilyana Yarabanova
- Radoslav Karaivanov | Date:
- Radoslav Mirchev | Date:
- Svilen Dimchevski | Date:
| Version | Author | Date | Notes |
|---|---|---|---|
| 1 | Riva Ivanova | 2025-03-17 | Initial draft - user stories, API, test scenarios |
| 1.1 | Riva Ivanova | 2025-03-20 | Updated draft specification |
| 1.2 | Riva Ivanova | 2025-04-02 | Finalized specification |
| 1.3 | Riva Ivanova | 2025-04-07 | Updated API, ARIA and test scenarios |
| 1.4 | Arkan Ahmedov | 2025-04-14 | Updated API and ARIA |
The igc-tooltip component provides us with a way to display a tooltip for a specific element.
A tooltip is a popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it. It typically appears after a small delay and disappears when Escape is pressed or on mouse leave.
The igc-tooltip must:
- support user-provided slotted content.
- expose a way to set an element instance or an IDREF as the anchor for the tooltip.
- expose a way to show/hide the tooltip manually.
- be WAI-ARIA compliant.
As an end-user, I expect to be able to:
- display a tooltip for an element when hovering with the mouse or focusing with the Tab key.
- hide the tooltip of an element when no longer hovering it with the mouse.
- interact with the content of the tooltip.
As a developer, I expect to be able to:
- display a tooltip for a specific element when hovered with the mouse or focused with the Tab key.
- hide the tooltip of a specific element when no longer interacting with it.
- manually show/hide the tooltip for a specific element without interacting with it.
- specify the delay time of a tooltip before it is shown.
- specify the delay time of a tooltip before it is hidden.
- specify the position at which the tooltip should be displayed.
- use a default template for the content of the tooltip with the ability to style it.
- provide a custom template for the content of the tooltip.
- enable/disable the tooltip from showing/hiding.
Target is specified by providing an IDREF.
<igc-tooltip anchor="hover-button">
Congrats you've hovered the button!
</igc-tooltip>
<igc-button id="hover-button">Hover me</igc-button>Target is specified by providing an Element.
<igc-tooltip id="tooltip">
Congrats you've hovered the button!
</igc-tooltip>
<igc-button id="hover-button">Hover me</igc-button>constructor() {
const anchor = document.querySelector('#hover-button') as IgcButtonComponent;
const tooltip = document.querySelector('#tooltip') as IgcTooltipComponent;
tooltip.anchor = anchor;
}If no anchor is provided, the tooltip will consider the first preceding sibling that is an element as the target.
<igc-button>Hover me</igc-button>
<igc-tooltip>
Congrats you've hovered the button!
</igc-tooltip><p>
Here is some text with a
<strong>element</strong>
<igc-tooltip>😎</igc-tooltip>
that has a tooltip.
</p>Text content can be provided via the message property.
<igc-button>Hover me</igc-button>
<igc-tooltip message="Congrats you've hovered the button!">
</igc-tooltip>Slotted content takes priority over the message property.
<igc-button>Hover me</igc-button>
<igc-tooltip message="I will be hidden.">
I will be shown!
</igc-tooltip>- If the tooltip is invoked when a pointing cursor moves over the target element, then it remains open as long as the cursor is over the target or the tooltip.
- When focusing the target via Tab key, the focus stays on the target element while the tooltip is displayed.
- If the tooltip is invoked when the trigger element receives focus, then it is dismissed when it no longer has focus (onBlur).
- The tooltip cannot be focused. Its elements could not be focused as well. The elements within a tooltip are not focusable but the user can interact with them.
- On initial open state, the tooltip does not close automatically after the number of milliseconds specified by
hideDelay. The tooltip will remain open until interacting with it or its target. - When the tooltip is set as
sticky:- It renders a default close button (
X). - It can be closed only by clicking the close button or pressing the
Esckey.
- It renders a default close button (
No specific implementation is needed.
| Key | Behavior |
|---|---|
| Escape | Dismisses the tooltip. |
| Property | Attribute | Reflected | Type | Default | Description |
|---|---|---|---|---|---|
open |
open |
Yes | boolean |
false |
Whether the tooltip is shown. |
disableArrow |
disable-arrow |
Yes | boolean |
false |
Whether to disable the rendering of the arrow indicator for the tooltip. |
inline |
inline |
Yes | boolean |
false |
Improves positioning for inline based elements, such as links. |
offset |
offset |
No | number |
6 |
The offset of the tooltip from the anchor in pixels. |
placement |
placement |
No | IgcPlacement |
top |
Where to place the floating element relative to the parent anchor element. |
anchor |
anchor |
No | string | Element |
- | An element instance or an IDREF to use as the anchor for the tooltip. |
showTriggers |
show-triggers |
No | string |
pointerenter |
Which event triggers will show the tooltip. Expects a comma separate string of different event triggers. |
hideTriggers |
hide-triggers |
No | string |
pointerleave click
|
Which event triggers will hide the tooltip. Expects a comma separate string of different event triggers. |
showDelay |
show-delay |
No | number |
200 | Specifies the number of milliseconds that should pass before showing the tooltip. |
hideDelay |
hide-delay |
No | number |
300 | Specifies the number of milliseconds that should pass before hiding the tooltip. |
message |
message |
No | string |
- | Specifies a plain text as tooltip content. |
sticky |
sticky |
No | boolean |
false |
Specifies if the tooltip remains visible until the user closes it via the close button or Esc key. |
| Name | Type signature | Description |
|---|---|---|
show |
(): Promise<boolean> |
Shows the tooltip if not already shown. |
hide |
(): Promise<boolean> |
Hides the tooltip if not already hidden. |
toggle |
(): Promise<boolean> |
Toggles between shown/hidden state. |
| Name | Cancellable | Description | Parameters |
|---|---|---|---|
igcOpening |
Yes | Emitted before the tooltip is shown. | { target: Element } |
igcOpened |
No | Emitted after the tooltip is shown. | { target: Element } |
igcClosing |
Yes | Emitted before the tooltip is hidden. | { target: Element } |
igcClosed |
No | Emitted after the tooltip is hidden. | { target: Element } |
| Name | Description |
|---|---|
(default) |
Default slot for the tooltip content. |
close-button |
Renders tooltip close button in sticky mode. |
| Part | Description |
|---|---|
- passes the default WAI-ARIA automation.
- is initialized without errors.
- is initialized with the appropriate default state.
- should correctly slot user-provided content for the tooltip.
- the tooltip is initially hidden.
- should show/hide the tooltip based on
showDelayandhideDelay. - should show/hide the tooltip based on the
openproperty. - should determine the tooltip's current state via the
openproperty. - should set target via
anchorpropety by providing an IDREF. - should set target via
anchorpropety by providing an Element. - should show/hide the arrow via the
disableArrowproperty. - should show/hide the arrow via the
disable-arrowattribute. - should show the tooltip via
show()method. - should hide the tooltip via
hide()method. - should toggle between shown/hidden state via
toggle()method. - should change the show/hide trigger via
showTriggers/hideTriggersproperty. - should change the show/hide trigger via
show-triggers/hide-triggersattribute. - should render a default close button when in
stickymode. - hide triggers should not close the tooltip when in
stickymode. - should close the tooltip when in
stickymode by clicking the default close button. - should close the tooltip when in
stickymode by pressing theEsckey. - should provide content via the
messageproperty. - slotted content takes priority over the
messageproperty.
- it should be shown when hovering over its target and hidden when the mouse leaves.
- it should be shown when focusing its target via Tab key and hidden when losing focus (on blur).
- it should be hidden when pressing Escape.
- events are correctly emitted on user interaction.
- events can be canceled.
role:
-
tooltipby default -
statuswhen thestickyproperty istrue
inert: updated depending on whether the tooltip is visible or not
aria-atomic: true
aria-live: polite
https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
https://www.w3.org/TR/wai-aria-1.2/#tooltip
The component should work in a Right-To-Left context without additional setup or configuration.
None applicable.