@svelte-put/tooltip
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@svelte-put/tooltip

npm.badge bundlephobia.badge docs.badge repl.badge

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>

Package Sidebar

Install

npm i @svelte-put/tooltip

Weekly Downloads

9

Version

1.0.2

License

MIT

Unpacked Size

25.5 kB

Total Files

8

Last publish

Collaborators

  • vnphanquang