npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@svelte-plugins/tooltips

v3.0.1

Published

A simple tooltip action and component designed for Svelte.

Downloads

16,359

Readme

@svelte-plugins/tooltips

A simple tooltip action and component designed for Svelte.

Try it in the Svelte REPL.

Install

yarn add @svelte-plugins/tooltips

# or with NPM

npm i @svelte-plugins/tooltips

# or with PNPM

pnpm i @svelte-plugins/tooltips

Using the Tooltip component

<script>
  import { Tooltip } from "@svelte-plugins/tooltips";
</script>

<Tooltip content="Hello world!">
 Check out my tooltip
</Tooltip>

Using the Tooltip action

<script>
  import { tooltip } from "@svelte-plugins/tooltips";
</script>

Checkout out my <u title="Hello World!" use:tooltip>tooltip</u>

Checkout out my <u use:tooltip={{ content: 'Hello World!' }}>tooltip</u>

API

Props

| Prop | Description | Value | | :----------------- | :------------------------------------------------------------------ | :---------------------------------------------- | | action | The action that triggers the tooltip (hover | click | prop) | string (default: hover) | | animation | The animation to apply to the tooltip | string (default: ) | | arrow | If `false`, the tooltip arrow will not be shown. | `boolean` (default: `true`) | | autoPosition | Adjust tooltip position if viewport clipping occurs | `boolean` (default: `false`) | | content | The string or object containing componentref and props | `string` | `object` component (default: ) | | delay | The animation delay in milliseconds to apply to the tooltip | number (default: 200) | | hideOnClickOutside | Hides a tooltip when an outside click occurs | boolean (default: false) | | maxWidth | The max allowable width of the tooltip content | number (default: 200) | | position | The position where the tooltip should appear relative to its parent | string (default: top) | | show | Allows you to manually control the tooltip visibility | boolean (default: false) | | style | The object containing theme variable overrides | object (default: null) | | theme | The CSS theme class name | string (default: ``) |

Using components as content

| Prop | Description | Value | | :-----------------| :------------------------------------------------------------------- | :---------------------------------------------- | | content.component | Svelte component | component (default: null) | | content.props | Any component propeties | object (default: null) |

<script>
  import ComponentAsTooltip from './ComponentAsTooltip';
</script>

Checkout out my <span use:tooltip={{ content: { component: ComponentAsTooltip, props: { title: 'Hello World!' } } }}>tooltip</span>

Theming

You can customize tooltips theme using several methods:

  • Assign a theme class name via the theme property that includes all of your CSS variables overrides
  • Define the overrides directly using the style property
  • Override the CSS variables globally

Tooltip CSS variables:

--tooltip-arrow-size: 10px;
--tooltip-background-color: rgba(0, 0, 0, 0.9);
--tooltip-border-radius: 4px;
--tooltip-box-shadow: 0 1px 20px rgba(0, 0, 0, 0.25);
--tooltip-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell,
  'Helvetica Neue', sans-serif;
--tooltip-font-size: 14px;
--tooltip-font-weight: 500;
--tooltip-line-height: 1.25rem;
--tooltip-color: #fff;
--tooltip-offset-x: 12px;
--tooltip-offset-y: 12px;
--tooltip-padding: 12px;
--tooltip-white-space-hidden: nowrap;
--tooltip-white-space-shown: normal;
--tooltip-z-index: 100;

Using the theme property

// action
<span title="hello world!" use:tooltip={{ theme: 'custom-tooltip' }}>Hover over me</span>

// component
<Tooltip content="hello world!" theme="custom-tooltip">Hover over me</Tooltip>

<style>
  :global(.tooltip.custom-tooltip) {
    --tooltip-background-color: hotpink;
    --tooltip-box-shadow: 0 1px 8px pink;
  }
</style>

Using the style property

// action
<span title="hello world!" use:tooltip={{ style: { backgroundColor: 'blue', borderRadius: '10px' } }}>Hover over me</span>

// component
<Tooltip content="hello world!" style={{ style: { backgroundColor: 'blue' } }}>Hover over me</Tooltip>

Changelog

Changelog

License

MIT