@svelte-put/tooltip
v1.0.2
Published
over-engineered, type-safe, headless, and extensible tooltip builder vs Svelte action
Downloads
81
Maintainers
Readme
@svelte-put/tooltip
Type-safe, headless, extensible tooltip builder via Svelte action use:tooltip
svelte-put
This package is part of the @svelte-put family. For contributing guideline and more, refer to its readme.
Usage & Documentation
See the dedicated documentation page here.
Quick Start
<script>
import { computePosition } from '@floating-ui/dom';
import { tooltip } from '@svelte-put/tooltip';
</script>
<button
class="c-btn-primary relative"
use:tooltip={{
content: 'An example tooltip',
class: 'c-tooltip',
compute: async ({ node, tooltip, content }) => {
const { x, y } = await computePosition(node, tooltip, {
placement: 'right',
});
tooltip.style.left = `${x}px`;
tooltip.style.top = `${y}px`;
},
}}
>
A button with tooltip
</button>