Skip to content

Library JS with ES6! No jQuery or Zepto, and etc... With only 2kb code (JS + CSS)

License

Notifications You must be signed in to change notification settings

figuarnieri/tipfy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tipfy - Simple Tooltip ES 6

A Javascript library ES6, without a dependency of jQuery, Zepto, and etc... Very simple to install and use. With only 4kb code (JS + CSS)

Install / Usage

Javascript

You can add Tipfy script in 3 ways: "CDN (ES6), ES5 script and Local Script"

CDN script

<script src="https://cdn.rawgit.com/figuarnieri/tipfy/master/js/tipfy.min.js"></script>

ES5 script

<script src="path/js/tipfy.es5.min.js"></script>

Local script

<script src="path/js/tipfy.min.js"></script>

Stylesheet

You can add Tipfy stylesheet in 2 ways: "CDN (Only Chrome and Firefox) and Local CSS (by scss)"

CDN style (Only Chrome and Firefox)

<link rel="stylesheet" href="https://cdn.rawgit.com/figuarnieri/tipfy/master/css/tipfy.min.css">

Local style (by scss)

<link rel="stylesheet" href="path/css/tipfy.min.css">

Instance Selector

You can instantiate Tipfy through standard CSS selectors

Selector by attribute

<i class="fa fa-user" data-tipfy="User Settings" aria-hidden="true" aria-label="User Settings"></i>

<script>
  new Tipfy('[data-tipfy]');
</script>

Selector by className

<i class="fa fa-user tooltip-by-class" aria-hidden="true" aria-label="User Settings"></i>

<script>
  new Tipfy('.tooltip-by-class');
</script>

Selector by className and attribute

<span class="section">
  <i class="fa fa-user" title="User Settings" aria-hidden="true" aria-label="User Settings"></i>
</span>

<script>
  new Tipfy('.section [title]');
</script>

Data attributes [data-*]

If necessary, you could add attributes in the tag, to configure your tooltips options

data-tipfy

Attribute to add text in your tooltip or HTML Element

<i data-tipfy="Simple Text"></i>
<i data-tipfy=".select-class"></i>

data-tipfy-side

Attribute to add direction side in your tooltip

  • [data-tipfy-side="top"] (default)
  • [data-tipfy-side="bottom"]
  • [data-tipfy-side="right"]
  • [data-tipfy-side="left"]
<i data-tipfy="Simple Text" data-tipfy-side="right"></i>

data-tipfy-class

Attribute to add one or more custom class

<i data-tipfy="Simple Text" data-tipfy-class="select-class-custom"></i>

data-tipfy-text

Add data-tipfy-text attribute to get raw text, if your tooltip text is a selector css

<i data-tipfy=".select-class" data-tipfy-text=""></i>

Source

Github | Example | @figuarnieri

License

The MIT License Copyright 2018 © Filipe Guarnieri