vUX / ToolTip / v4.1.0

Every bar has something to say.

One ToolTip, one class, twenty-four bars. Point at any of them: the tip rides the pointer, stays inside the window at both edges, and flips below when the top runs out (try the editor bar above).

Requests / hour / today hover a bar
00:0006:0012:0018:0023:00
class tip-bar, amber tip peak hours class tip-tool, a second instance
tip.config.className = "tip-bar"; tip.initialize();

01Playground

Every chip on the stage is a member of one ToolTip (class tip-play). Change the colours, switch HTML on, turn single members off and on, add members at runtime and rewrite a title. The panel on the right shows what the module did to the first chip.

config.tipBoxStyles
Members: on() / off()
Runtime changes
stage
01Plain 02Has children 03Markup 04Long text 05Empty title
no tip showing
First chip, live markup

                
Equivalent code

                

02Keyboard

Press Tab into this row. Focusing a member shows its tip at the member, blur hides it, and Esc dismisses it. A focus-opened tip follows its member when the page scrolls; a pointer-opened one hides instead. The shown member carries aria-describedby pointing at the tip.

aria-describedby: none

03Edges and long text

The tip is fixed to the viewport and kept 4px inside the window. Point at the far left and far right pins: the box is pushed in from the edge, while the arrow (the --vtt-arrow-left custom property) keeps pointing at the pointer.

left edge a long tip, wrapped right edge

04Lifecycle

destroy() removes the listeners, the tip box and the generated stylesheet and gives every member its title back, so the browser's own tooltip returns. A destroyed instance cannot be initialized again: create a new one.

class tip-lifeinitialized
AAlpha BBeta
What the page holds

            

05Bad input throws

Each button below makes a call the module rejects and prints the Error it throws. A rejected call changes nothing: the playground keeps its colours.

No error yet. Press one of the buttons above.