Tiny edge-aware tooltips. One attribute, one config call, no dependencies, no build. Works in all modern browsers.
Then mark any element with the attribute. Tooltips show on hover and keyboard focus, and hide on Esc.
Style and behavior are global. Call tolltop() once with any subset of options.
Try it live, then hover any tooltip on the page:
Works on inline spans and dynamic nodes too.
The four pinned buttons in the page corners stay open-aware: corners near the top flip below, and corners near a side shift inward so the box never clips. The arrow keeps pointing at the trigger.
Tip: shrink the window narrow to watch the long tooltip wrap.
| Option | Example | Default |
|---|---|---|
bg | '#1e3a5f' | #18181b |
color | '#fff' | #e4e4e7 |
radius | 10 or '10px' | 6 |
fontSize | 14 or '0.9rem' | 12 |
padding | '8px 12px' | 6px 9px |
maxWidth | 320 | 240 |
placement | 'top' / 'bottom' | auto |
gap | 12 | 10 |
edge | 16 | 24 |
The trigger attribute stays data-tooltip="text". Everything else is configured here.