Skip to content

Tooltip ​

A simple text popup box.

Importing ​

To use the tooltip component, first you need to register the component inside the page. You can register the component manually by importing the register function:

ts
import { register } from "@tapsioss/web-components/tooltip";

register(); // Now the tooltip component is ready to use!
ts
import { registerTooltip } from "@tapsioss/web-components";

registerTooltip(); // Now the tooltip component is ready to use!

Also you can automatically register the component by importing it with the following approach:

ts
import "@tapsioss/web-components/tooltip/element";

TIP

If you want to use all the component in your app, you can call registerAll at the root of your project.

ts
import { registerAll } from "@tapsioss/web-components";

registerAll(); // All the components are now available

In the React package, you can easily add the component using the following code:

ts
import { Tooltip } from "@tapsioss/react-components";

Component Usage ​

html
<tapsi-tooltip></tapsi-tooltip>
tsx
<Tooltip />

Properties ​

NameAttribute NameDescriptionTypeDefault Value
placementplacementControls how to position the tooltip relative to the anchor.| "top"
| "top-start"
| "top-end"
| "right"
| "right-start"
| "right-end"
| "bottom"
| "bottom-start"
| "bottom-end"
| "left"
| "left-start"
| "left-end"
"top"
dismissibledismissibleWhether tooltip is dismissable or not.booleanfalse
texttextThe text content of the tooltip.string""
anchoranchorThe id of the anchor element.string""
visiblevisibleWhether the tooltip is visible or not.booleanfalse
noHoverActivationno-hover-activationWhether to prevent showing tooltip on hover or not.booleanfalse
noFocusActivationno-focus-activationWhether to prevent showing tooltip on focus or not.booleanfalse
noEscapeDeactivationno-escape-deactivationWhether to hide tooltip on escape or not.booleanfalse

Methods ​

NameDescriptionParameters
showForces the tooltip to display.
hideForces the tooltip to hide.
updateTooltipPositionCalculates and updates the position of the tooltip based on
Its anchor element.

Events ​

NameDescriptionTypeBubblesCancelable
showFires when the tooltip should be visible.ShowEvent❌✅
hideFires when the tooltip should be hidden.HideEvent❌✅

TIP

Event details are available as JavaScript variables:

ts
// Option 1
import {
 ShowEvent,
 HideEvent
} from "@tapsioss/web-components/tooltip";

// Option 2
import {
 TooltipShowEvent,
 TooltipHideEvent
} from "@tapsioss/web-components";

You can have access to the event name using the type property:

ts
// Option 1
element.addEventListener(ShowEvent.type, handleShow);
element.addEventListener(HideEvent.type, handleHide);

// Option 2
element.addEventListener(TooltipShowEvent.type, handleShow);
element.addEventListener(TooltipHideEvent.type, handleHide);

Created with 🧡