Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hint

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hint

Awesome tooltips at your fingertips

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
increased by21.13%
Maintainers
1
Weekly downloads
 
Created
Source

hint

Awesome pure CSS tooltips at your fingertips

Install

Using Bower

bower install -S hint

Using npm

npm install -S hint

Usage

Just give your elements a nice tooltip in HTML. When hovered, the hint will appear.

<span data-hint='foobar'>Foo Bar</span>

You'll get a nice little tooltip. Remember to include the CSS in your styles!

hint.png

By default, the :after pseudo-selector is used. This means you can use the :before pseudo-selector for your own purposes. If you want the data-hint to use :before, then you must use the hint-before class on the element as well.

<span data-hint='foobar' class='hint-before'>Foo Bar</span>

You can also use the aria-label attribute.

<span aria-label='foobar'>Foo Bar</span>

If you want the aria-label hint to use :before, then you must use the hint-before class on the element as well.

<span aria-label='foobar' class='hint-before'>Foo Bar</span>

Hints have a z-index of 5000.

JavaScript

The CSS will only get us so far, and we must add a tiny bit of JavaScript if we want a little functionality. This is not critical to hint, and is therefore considered an optional feature. The JavaScript code enables the following features.

  • Hints are docked to the visible viewport so that they aren't cut off when they're near the edge
  • If hints are even wider than the viewport itself, then they are rendered in multi-line, setting the max width to the viewport width
  • You can define a maximum width to avoid hard-to-read long hints in wide viewports
  • When the JavaScript snippet is used, hints transition into view a second after the target element is hovered

To include the JavaScript, just use the following snippet if you're using CommonJS, or refer to the dist directory for the compiled distributions.

require('hint');

To set the maximum hint width, do:

require('hint').maximumWidth = 650;

You can also set it to 'auto', which means the full viewport size will be used if the tooltip exceeds the viewport size in length. In practice, 'auto' means Infinity will be used. The default maximumWidth value is 650 pixels wide.

License

MIT

FAQs

Package last updated on 30 Sep 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc