Convert Figma logo to code with AI

atomiks logotippyjs

Tooltip, popover, dropdown, and menu library

11,899
520
11,899
104

Top Related Projects

A JavaScript library to position floating elements and create interactions for them.

A JavaScript library to position floating elements and create interactions for them.

A JavaScript library to position floating elements and create interactions for them.

A CSS only tooltip library for your lovely websites.

22,354

A light-weight, no-dependency, vanilla JavaScript engine to drive user's focus across the page

Quick Overview

Tippy.js is a highly customizable tooltip and popover library powered by Popper.js. It provides an easy way to add tooltips, popovers, dropdowns, and more to web applications with minimal effort and maximum flexibility.

Pros

  • Lightweight and performant
  • Extensive customization options
  • Accessibility-focused with ARIA support
  • Works with various frameworks (React, Vue, Angular)

Cons

  • Learning curve for advanced customizations
  • Requires Popper.js as a dependency
  • Some features may require additional plugins
  • Documentation can be overwhelming for beginners

Code Examples

  1. Basic tooltip:
tippy('#myButton', {
  content: 'Hello, I am a tooltip!',
});
  1. Customized tooltip with HTML content:
tippy('#myElement', {
  content: '<strong>Bold</strong> and <em>italic</em> text',
  allowHTML: true,
  animation: 'scale',
  theme: 'light',
});
  1. Tooltip with custom positioning and arrow:
tippy('#myImage', {
  content: 'Image description',
  placement: 'bottom-start',
  arrow: true,
  arrowType: 'round',
});
  1. Programmatically controlled tooltip:
const instance = tippy('#myTarget', {
  content: 'Dynamically updated content',
  trigger: 'manual',
});

// Show the tooltip
instance.show();

// Update content
instance.setContent('New content');

// Hide the tooltip
instance.hide();

Getting Started

  1. Install Tippy.js via npm:
npm install @tippyjs/react
  1. Import and use Tippy in your React component:
import React from 'react';
import Tippy from '@tippyjs/react';
import 'tippy.js/dist/tippy.css'; // optional for styling

function App() {
  return (
    <Tippy content="Hello, Tippy!">
      <button>Hover me</button>
    </Tippy>
  );
}

export default App;

For non-React projects, include Tippy.js via CDN and initialize:

<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<script>
  tippy('#myElement', {
    content: 'My tooltip content',
  });
</script>

Competitor Comparisons

A JavaScript library to position floating elements and create interactions for them.

Pros of Floating UI

  • More flexible and customizable positioning system
  • Framework-agnostic, can be used with any UI library or vanilla JavaScript
  • Smaller bundle size for core functionality

Cons of Floating UI

  • Requires more setup and configuration for basic use cases
  • Less out-of-the-box styling and theming options
  • Steeper learning curve for beginners

Code Comparison

Tippy.js:

tippy('#myButton', {
  content: 'Hello, world!',
  placement: 'top',
  animation: 'scale'
});

Floating UI:

import {computePosition, flip, shift, offset} from '@floating-ui/dom';

computePosition(button, tooltip, {
  placement: 'top',
  middleware: [offset(6), flip(), shift({padding: 5})]
}).then(({x, y}) => {
  Object.assign(tooltip.style, {
    left: `${x}px`,
    top: `${y}px`,
  });
});

Floating UI provides more granular control over positioning and behavior, while Tippy.js offers a simpler API for common use cases. Floating UI is better suited for complex, custom positioning requirements, whereas Tippy.js excels in quickly implementing tooltips and popovers with minimal configuration.

A JavaScript library to position floating elements and create interactions for them.

Pros of Floating UI

  • More flexible and customizable positioning system
  • Framework-agnostic, can be used with any UI library or vanilla JavaScript
  • Smaller bundle size for core functionality

Cons of Floating UI

  • Requires more setup and configuration for basic use cases
  • Less out-of-the-box styling and theming options
  • Steeper learning curve for beginners

Code Comparison

Tippy.js:

tippy('#myButton', {
  content: 'Hello, world!',
  placement: 'top',
  animation: 'scale'
});

Floating UI:

import {computePosition, flip, shift, offset} from '@floating-ui/dom';

computePosition(button, tooltip, {
  placement: 'top',
  middleware: [offset(6), flip(), shift({padding: 5})]
}).then(({x, y}) => {
  Object.assign(tooltip.style, {
    left: `${x}px`,
    top: `${y}px`,
  });
});

Floating UI provides more granular control over positioning and behavior, while Tippy.js offers a simpler API for common use cases. Floating UI is better suited for complex, custom positioning requirements, whereas Tippy.js excels in quickly implementing tooltips and popovers with minimal configuration.

A JavaScript library to position floating elements and create interactions for them.

Pros of Floating UI

  • More flexible and customizable positioning system
  • Framework-agnostic, can be used with any UI library or vanilla JavaScript
  • Smaller bundle size for core functionality

Cons of Floating UI

  • Requires more setup and configuration for basic use cases
  • Less out-of-the-box styling and theming options
  • Steeper learning curve for beginners

Code Comparison

Tippy.js:

tippy('#myButton', {
  content: 'Hello, world!',
  placement: 'top',
  animation: 'scale'
});

Floating UI:

import {computePosition, flip, shift, offset} from '@floating-ui/dom';

computePosition(button, tooltip, {
  placement: 'top',
  middleware: [offset(6), flip(), shift({padding: 5})]
}).then(({x, y}) => {
  Object.assign(tooltip.style, {
    left: `${x}px`,
    top: `${y}px`,
  });
});

Floating UI provides more granular control over positioning and behavior, while Tippy.js offers a simpler API for common use cases. Floating UI is better suited for complex, custom positioning requirements, whereas Tippy.js excels in quickly implementing tooltips and popovers with minimal configuration.

A CSS only tooltip library for your lovely websites.

Pros of hint.css

  • Lightweight and CSS-only solution, no JavaScript required
  • Easy to implement with minimal setup
  • Works well for simple tooltip needs without additional dependencies

Cons of hint.css

  • Limited customization options compared to Tippy.js
  • Lacks advanced positioning and animation features
  • No programmatic control or dynamic content support

Code Comparison

hint.css:

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

Tippy.js:

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

Summary

hint.css is a lightweight, CSS-only tooltip solution that's easy to implement for simple use cases. It requires minimal setup and works well for basic tooltip needs. However, it lacks the advanced features, customization options, and programmatic control offered by Tippy.js.

Tippy.js, on the other hand, provides a more robust and feature-rich tooltip solution with extensive customization options, advanced positioning, and dynamic content support. It requires JavaScript but offers greater flexibility and control over tooltip behavior and appearance.

Choose hint.css for quick, simple tooltip implementations, and Tippy.js for more complex, customizable tooltip requirements in larger projects.

22,354

A light-weight, no-dependency, vanilla JavaScript engine to drive user's focus across the page

Pros of Driver.js

  • Focuses on guided tours and feature introductions
  • Lightweight and dependency-free
  • Supports multiple highlight shapes (circle, rectangle)

Cons of Driver.js

  • Less flexible for general-purpose tooltips
  • Fewer positioning options compared to Tippy.js
  • Smaller community and ecosystem

Code Comparison

Driver.js:

const driver = new Driver();
driver.highlight({
  element: '#my-element',
  popover: {
    title: 'Title',
    description: 'Description'
  }
});

Tippy.js:

tippy('#my-element', {
  content: 'Description',
  placement: 'top',
  animation: 'scale'
});

Summary

Driver.js is better suited for creating guided tours and highlighting specific elements on a page, while Tippy.js excels at providing flexible and customizable tooltips for various use cases. Driver.js is lightweight and dependency-free, making it a good choice for projects that prioritize simplicity and small bundle size. However, Tippy.js offers more advanced positioning options and has a larger community, which can be beneficial for complex tooltip requirements and long-term support.

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

Tippy.js logo

Tippy.js

The complete tooltip, popover, dropdown, and menu solution for the web

npm Downloads per Month MIT License

Demo and Documentation

➡️ View the latest demo & docs here

Migration Guide

Installation

Package Managers

# npm
npm i tippy.js

# Yarn
yarn add tippy.js

Import the tippy constructor and the core CSS:

import tippy from 'tippy.js';
import 'tippy.js/dist/tippy.css';

CDN

<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>

The core CSS comes bundled with the default unpkg import.

Usage

For detailed usage information, visit the docs.

Component Wrappers

License

MIT

NPM DownloadsLast 30 Days