Convert Figma logo to code with AI

chinchang logohint.css

A CSS only tooltip library for your lovely websites.

8,418
702
8,418
54

Top Related Projects

11,899

Tooltip, popover, dropdown, and menu library

💬 Minimal, accessible, ultra lightweight css tooltip library. Just 1kb.

Simple tooltips made of pure CSS

Quick Overview

hint.css is a pure CSS tooltip library that provides an easy way to add tooltips to HTML elements without relying on JavaScript. It offers a lightweight solution for creating customizable and responsive tooltips with various positioning options and animations.

Pros

  • Lightweight and dependency-free, as it's a pure CSS solution
  • Easy to implement and customize with minimal markup
  • Supports multiple positioning options and animations
  • Responsive and works well across different devices and screen sizes

Cons

  • Limited functionality compared to JavaScript-based tooltip libraries
  • May require additional CSS for complex tooltip designs
  • Lacks advanced features like dynamic content loading or event-based triggers
  • Browser compatibility issues with older versions of Internet Explorer

Code Examples

  1. Basic tooltip:
<span class="hint--top" aria-label="This is a tooltip">Hover me</span>
  1. Tooltip with custom position and animation:
<span class="hint--bottom hint--bounce" aria-label="Bouncing tooltip">Hover for bounce</span>
  1. Tooltip with HTML content:
<span class="hint--html hint--info hint--top" data-hint="
  <h3>HTML Tooltip</h3>
  <p>This tooltip contains <em>HTML content</em>.</p>
">
  Hover for HTML tooltip
</span>

Getting Started

  1. Include the hint.css file in your HTML:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.7.0/hint.min.css">
  1. Add the appropriate classes and aria-label to your HTML elements:
<span class="hint--top" aria-label="This is a tooltip">Hover me</span>
  1. Customize tooltips by adding additional classes or modifying the CSS:
<span class="hint--bottom hint--warning" aria-label="Warning tooltip">Hover for warning</span>

That's it! Your tooltips should now be functional and styled according to the hint.css library.

Competitor Comparisons

11,899

Tooltip, popover, dropdown, and menu library

Pros of Tippyjs

  • More feature-rich with advanced positioning, animations, and interactivity
  • Highly customizable with extensive API and options
  • Better browser support, including legacy browsers

Cons of Tippyjs

  • Larger file size and potentially higher performance overhead
  • Steeper learning curve due to more complex API
  • Requires JavaScript, unlike hint.css which is CSS-only

Code Comparison

hint.css (HTML):

<span class="hint--top" aria-label="This is a tooltip">Hover me</span>

Tippyjs (JavaScript):

tippy('#myElement', {
  content: 'This is a tooltip',
  placement: 'top'
});

Summary

Tippyjs offers more advanced features and customization options, making it suitable for complex tooltip requirements. It provides better browser support but comes with a larger file size and requires JavaScript. hint.css, on the other hand, is a lightweight, CSS-only solution that's easier to implement for simple tooltip needs but lacks advanced functionality.

Choose Tippyjs for feature-rich, interactive tooltips with extensive customization options. Opt for hint.css when you need a simple, lightweight tooltip solution without JavaScript dependencies.

💬 Minimal, accessible, ultra lightweight css tooltip library. Just 1kb.

Pros of microtip

  • Smaller file size (1.5KB vs 6KB for hint.css)
  • No JavaScript required, pure CSS solution
  • Simpler implementation with fewer classes and options

Cons of microtip

  • Limited customization options compared to hint.css
  • Fewer positioning options for tooltips
  • Less extensive browser support documentation

Code Comparison

microtip:

<button aria-label="Label text" data-microtip-position="top" role="tooltip">
  Hover me
</button>

hint.css:

<span class="hint--top" aria-label="Label text">
  Hover me
</span>

Both libraries use similar HTML attributes for tooltip content and positioning. microtip uses data-microtip-position for positioning, while hint.css uses CSS classes like hint--top. microtip requires the role="tooltip" attribute, which is not necessary for hint.css.

Overall, microtip is a lightweight alternative to hint.css, offering a simpler implementation at the cost of fewer customization options. hint.css provides more flexibility and features but comes with a larger file size and more complex usage.

Simple tooltips made of pure CSS

Pros of balloon.css

  • Simpler implementation with fewer CSS classes required
  • Supports more positioning options (top, bottom, left, right, up-left, up-right, down-left, down-right)
  • Includes built-in animations for smoother appearance/disappearance

Cons of balloon.css

  • Less customization options compared to hint.css
  • Smaller community and fewer updates (last update in 2021 vs 2023 for hint.css)
  • Limited theme options out of the box

Code Comparison

balloon.css:

<button aria-label="This is a tooltip" data-balloon-pos="up">Hover me!</button>

hint.css:

<span class="hint--top" aria-label="This is a tooltip">Hover me!</span>

Both libraries aim to provide simple, CSS-only tooltips without JavaScript dependencies. balloon.css focuses on ease of use with a single data attribute, while hint.css offers more customization options through multiple CSS classes. hint.css has a larger community and more frequent updates, potentially providing better long-term support and feature additions. However, balloon.css's simpler implementation and built-in animations may be preferable for projects requiring quick and straightforward tooltip solutions.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Hint.css npm version downloads/month Join the chat at https://gitter.im/chinchang/hint.css gzip size

A tooltip library in CSS for your lovely websites

Demo • Get started • Who's using this? • Browser support • FAQs • Contributing • License

hint.css is written as a pure CSS resource using which you can create cool accessible tooltips for your web app. It does not rely on JavaScript but rather uses aria-label/data-* attribute, pseudo elements, content property and CSS3 transitions to create the tooltips. Also it uses BEM naming convention particularly for the modifiers.

Get Started

Get the library using one of the following ways:

  1. GitHub

Full build

Base build (Does not include color themes and fancy effects)

  1. Bower : bower install hint.css

  2. npm: npm install --save hint.css

  3. CDN: https://www.jsdelivr.com/package/npm/hint.css or https://cdnjs.com/libraries/hint.css

Now include the library in the HEAD tag of your page:

<link rel="stylesheet" href="hint.css" />

or

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

Now, all you need to do is give your element any position class and tooltip text using the aria-label attribute. Note, if you don't want to use aria-label attribute, you can also specify the tooltip text using the data-hint attribute, but its recommended to use aria-label in support of accessibility. Read more about aria-label.

Hello Sir, <span class="hint--bottom" aria-label="Thank you!">hover me.</span>

Use it with other available modifiers in various combinations. Available modifiers:

  • Colors - hint--error, hint--info, hint--warning, hint--success
  • Sizes - hint--small, hint--medium, hint--large, hint--fit
  • hint--always
  • hint--rounded
  • hint--no-animate
  • hint--bounce
  • hint--no-arrow
  • hint--no-shadow

Upgrading from v1.x

If you are already using v1.x, you may need to tweak certain position classes because of the way tooltips are positioned in v2.

Changing the prefix for class names

Don't like BEM naming (hint--) or want to use your own prefix for the class names?

Simply update src/hint-variables.scss and change the $hintPrefix variable. To generate the css file, please read the contributing page.

Who's Using This?

Are you using hint.css in your awesome project too? Just tweet it out to @hint_css or let us know on the mailing list.

Browser Support

hint.css works on all latest browsers

FAQs

Checkout the FAQ Wiki for some common gotchas to be aware of while using hint.css.

Contributing

hint.css is developed in SASS and the source files can be found in the src/ directory.

If you would like to create more types of tooltips/ fix bugs/ enhance the library etc. you are more than welcome to submit your pull requests.

Read more on contributing.

Changelog & Updates

See the Changelog.

To catch all updates and discussion, join the mailing list: hintcss@googlegroups.com.

Or follow on twitter: @hint_css

License

Hint.css is free for personal and commercial use under the MIT License.

Credits

This doesn't make use of a lot of BEM methodology but big thanks to @csswizardry, @necolas for their awesome articles on BEM and to @joshnh through whose work I came to know about it :)

Sponsor

NPM DownloadsLast 30 Days