Socket
Socket
Sign inDemoInstall

svelte-tooltip

Package Overview
Dependencies
11
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-tooltip

### Table of contents


Version published
Weekly downloads
824
increased by22.8%
Maintainers
1
Install size
408 kB
Created
Weekly downloads
 

Readme

Source

Svelte Tooltip

Table of contents

  • Getting Started
  • Properties
  • Useful tips

Getting Started

Instalation

To install Svelte Tooltip into your svelte project use your package manager npm/yarn run one of the following commands on your terminal.

npm install svelte-tooltip or yarn add svelte-tooltip

Usage

Svelte Tooltip is really simple to use, first you need to import it on a script section

<script>
	import SvelteTooltip from 'svelte-tooltip';
</script>

and then use it on your component html template, passing as slot whatever you want to trigger the tooltip when hovered, usually these is going to be a button, icon, image, or a link.

<SvelteTooltip tip="view on github" bottom >
	<button>Click me</button>
</SvelteTooltip>

**Important: ** make sure to allways use one and just one directional prop, top, right, bottom, or left , those will position the tooltip according to the slot will passed, and not setting any or setting multiple will cause undefined behavior.

Properties

active

The active allows you to programmatically display a tooltip rather than waiting to a user hover, it's expected type is boolean and it defaults to false.

<SvelteTooltip tip="this is visible" left active>

color

The default Svelte Tooltip background-color is #757575, however you can easily change that with the color property, it's type is String and any css valid color is also valid for this property.

<SvelteTooltip tip="change the color" top color="#FFB74D">
tip

tip property is the actual text displayed inside the tooltip.

<SvelteTooltip tip="view on github" bottom >
Directional Props

The directional props allows you to position your tooltip in relation to the slot you give to the tooltip. As mentioned above SvelteTooltip should take exactly one directional prop.

top

<SvelteTooltip tip="I'm on the top" top >

right

<SvelteTooltip tip="I'm on the right" right >

bottom

<SvelteTooltip tip="I'm on the bottom" bottom >

left

<SvelteTooltip tip="I'm on the left" left >

Useful tips

Changing text color

Svelte tooltip has no default way of changing it's text color, however since the tooltip component inherits the text color from it's parent. The recomended way to set the text color is by wrapping the tooltip inside a div and use the css color attribute on it.

<style>
.wrapper {
  color: #fafafa;
}
</style>

<div class="wrapper">
	<SvelteTooltip tip="white text" bottom  color="#EF6C00">
		<button>Click me</button>
	</SvelteTooltip>
</div>

Keywords

FAQs

Last updated on 30 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc