Simple tooltip using an html attribute for the content
$ npm install cssrecipes-tooltip
Example:
<span class="r-Tooltip r-Tooltip--bottom" data-r-tooltip="I'm the tooltip body">Hover me to see the tooltip !</span>
Force visibility (no need to hover).
Add a avoid whitespace to wrap content (force content to be on one line).
Add text-align: center
on the tooltip content.
:root {
--r-Tooltip-zIndex: 1000;
--r-Tooltip-backgroundColor: #383838;
--r-Tooltip-margin: .5rem;
--r-Tooltip-arrow-size: .5rem;
}
If custom properties are not enough, you can obviously override default rules. Or add modifier(s).
It's easy to add a success
or error
state.
.r-Tooltip--STATE::before {
background-color: var(--r-Tooltip--STATE-color);
text-shadow: 0 -1px 0 color(var(--r-Tooltip--STATE-color) blackness(90%));
}
.r-Tooltip--STATE.r-Tooltip--top::after { border-top-color: var(--r-Tooltip--STATE-color) }
.r-Tooltip--STATE.r-Tooltip--bottom::after { border-bottom-color: var(--r-Tooltip--STATE-color) }
.r-Tooltip--STATE.r-Tooltip--left::after { border-left-color: var(--r-Tooltip--STATE-color) }
.r-Tooltip--STATE.r-Tooltip--right::after { border-right-color: var(--r-Tooltip--STATE-color) }
To generate a build:
$ npm run build
To generate the testing build.
$ npm run build-test
Basic visual tests are in test/index.html
.
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
$ git clone https://github.com/cssrecipes/tooltip.git
$ git checkout -b patch-1
$ npm install
$ npm test