Tooltip extends Floater

Assign a message to show on hover.

Example

JS
new Tooltip({
    content: "Hello World",
    anchor: '#hi-button'
})
HTML
<komp-tooltip anchor="#hi-button">
    Hello World
</komp-tooltip>

Constructor

new Tooltip(options)
options : Object optional
timeout : number optional

ms to wait until hiding after mouseout

scope : string optional

showing a tooltip will hide all other tooltips of same scope

enabled : boolean optional

set starting state

content : string | HTMLElement | Array | Object optional

content for the floater, uses Dolla's content

anchor : HTMLElement

element to anchor positioning to

container : string | HTMLElement optional

element to append floater to. If String, then used as selector for this.closest(selector)

placement : string optional

how the floater is anchored, e.g. "top", "top-start", "top-end", "left", "left-start"...

strategy : string optional

how the floater is positioned in the document. "absolute" or "fixed"

flip : boolean | Object optional

See https://floating-ui.com/docs/flip, defaults to false in favor of autoPlacement

offset : boolean | Object optional
shift : boolean | Object optional
arrow : boolean | number optional

True to show default size, or number in pixels

size : boolean | Object optional
autoPlacement : boolean | Object optional
inline : boolean | Object optional
autoUpdate : boolean | Object optional
removeOnBlur : boolean optional

hide floater on outside click/focus or escape key

onHide : function optional

called after hidden

onShow : function optional

called before showing

Instance Properties

Attributes settable via constructor options

Methods overridable via constructor options

Methods to auto-bind to this

Event names that can be bound via onEventName constructor options

CSS injected once per component via adoptedStyleSheets

Attributes to observe for changes. Triggers changed(attribute, was, now) and [attribute]Changed(was, now) callbacks.

Instance Methods

Listen for events on another element, automatically cleaned up when this component disconnects

Parameters

element : HTMLElement

element to listen on

eventType : string

event type

args : *

additional arguments passed to addEventListener

Called every time an observed attribute changes. Attribute must be listed in static watch.

Parameters

attribute : string

the attribute that changed

was : *

previous value

now : *

new value

Called when element is connected to the DOM

Called when element is disconnected from the DOM

Called once per instantiation, but only after element is connected to the DOM

Remove element. Fires beforeRemove, calls optional callback, removes from DOM, then fires afterRemove.

Parameters

callback : function optional

async callback called between beforeRemove and afterRemove

Returns

Toggle the floater visibility

Parameters

shouldHide : boolean optional

explicitly show or hide. If omitted, toggles based on current visibility.

Returns

Floater

this

Trigger an event on this element

Parameters

eventName : string

event name to trigger

args : *

additional arguments

Events

Fired after the element is connected to the DOM and initialized

Fired after the element is disconnected from the DOM

Fired after the element is removed

Fired before the element is connected to the DOM

Fired before the element is disconnected from the DOM

Fired before the element is removed

Fired when the floater is hidden

Fired when the floater is shown