Beautiful, flexible, and easy-to-use tooltips for Svelte. Create reusable tooltip styles, customize colors, borders, and positions β all with a tiny footprint β¨
createTipster() to define reusable tooltip presetsuse:tooltip directive for quick usagetop, bottom, left, right)npm install tipsterjs
# or
yarn add tipsterjs
# or
pnpm add tipsterjs
<script>
import { createTipster, tooltip } from 'tipsterjs';
const redTooltip = createTipster({
backgroundColor: 'red',
color: 'white',
borderColor: 'darkred',
borderWidth: '2px',
fontSize: '14px',
position: 'top',
offset: 30
});
</script>
<h1>Tipster Demo</h1>
<p>
Visit
<a
use:redTooltip={{ offset: 5 }}
title="Custom reusable tooltip"
href="https://svelte.dev/docs/kit"
>
svelte.dev/docs/kit
</a>
to read the documentation
</p>
<p>
Or try a quick inline tooltip:
<a
use:tooltip={{ backgroundColor: 'blue', color: 'white', position: 'bottom' }}
title="Dynamic tooltip powered by Tipster"
>
hover me
</a>
</p>
use:tooltipAttach a tooltip directly to any element.
Props:
| Prop | Type | Default | Description |
|---|---|---|---|
backgroundColor |
string |
#333 |
Tooltip background color |
color |
string |
#fff |
Text color |
borderColor |
string |
transparent |
Border color |
borderWidth |
string |
0 |
Border thickness |
fontSize |
string |
12px |
Text size |
position |
'top' | 'bottom' | 'left' | 'right' |
bottom |
Tooltip position |
offset |
number |
12 |
Distance from target element |
delay |
number |
100 |
Delay before showing tooltip |
createTipster(defaults)Create a reusable tooltip directive with shared defaults.
const myTooltip = createTipster({
backgroundColor: '#222',
color: '#fff',
position: 'top'
});
Then use it anywhere:
<a use:myTooltip={{ offset: 10 }} title="Hello!">Hover me</a>
Tipster:
title attributeLightweight, no dependencies, and works seamlessly in any Svelte project πͺ
Got an idea? Found a bug? PRs and issues are always welcome π
git clone https://github.com/mostafa-kheibary/Tipster
cd Tipster
pnpm install
pnpm dev
MIT β do whatever you want, just donβt remove the credit π