simple css js tooltip
Note that you can show both simple text or complex html in you'r tooltip. For html tag you should use HTML entities (character entities)
instead of tags itself, for example
text before break line <br/> text after break line
you shuld do it like this:
<span data-tooltip="text before break line <br/> text after break line" data-positions="right,top">hover me to show tooltip</span>
for html entities visit here: html entities
npm i @sohrabi/tooltip
import { initTooltip } from "@sohrabi/tooltip";
data attribute | description |
---|---|
tooltip | Text Or Html to show as tooltip |
positions | Comma separated list of positions to change the positioning default priority is as follow: bottom, top, right, left, bottomleft, bottomright, topleft, topright |
<span data-tooltip="test tooltip" data-positions="right,top">hover me to show tooltip</span>
const tooltipInstance = initTooltip();
tooltipInstance.destroy();
name | default |
---|---|
disableOnMobile | false |
color | #fff |
backgroundColor | #000 |
borderRadius | 4px |
const tooltipInstance = initTooltip({
disableOnMobile: true,
backgroundColor: "lightyellow",
color: "#9e0101"
});
If you want to use this library in you'r ES5 application, simple refrence the following js file.
<script type="text/javascript" src="https://unpkg.com/@sohrabi/tooltip/dist/index.js"></script>