--- title: Demo path: / index: 0 --- import {ALL_PLACEMENTS, EXTRA_ANIMATIONS} from '../utils'; import Dropdown from '../components/examples/Dropdown'; import Singleton from '../components/examples/Singleton'; import Nesting from '../components/examples/Nesting'; import {css} from '@emotion/core'; import brain from '../images/brain.svg'; import lightning from '../images/lightning.svg'; import pointer from '../images/pointer.svg'; import wheelchair from '../images/wheelchair.svg'; import paintbrush from '../images/paintbrush.svg'; import typescript from '../images/typescript.svg'; import browser from '../images/browser.svg'; Tippy.js is the complete tooltip, popover, dropdown, and menu solution for the web, powered by [Popper](https://popper.js.org). It provides the logic and optional styling of elements that "pop out" from the flow of the document and float next to a target element. - Smart: will always float optimally in view - Universal: compatible with mouse, keyboard, and touch inputs - Customizable: fine-tunable functionality and fully stylable with CSS - Typed: TypeScript support Ready to start? Visit [Getting Started](/v6/getting-started/), or view a demo of Tippy's features below. --- ### Default The default tippy tooltip looks like this: It is triggered by either `mouseenter` or `focus` events so it appears when hovered, focused via keyboard navigation, or tapped when using a touch device. With a button element on the document like this: ```html ``` You can initialize it like so: ```js tippy('#myButton', { content: "I'm a Tippy tooltip!", }); ``` --- ### Placements Your tippy can be placed in four base ways in relation to the reference element. Additionally, the tooltip can be shifted along the axis. {ALL_PLACEMENTS.map((placement, i) => ( ))} ```js tippy(button, { // default placement: 'top', }); ``` If a tippy cannot fit within its desired placement, it will flip to the opposite placement if there is not enough space. In the above examples, flipping has been disabled to demonstrate each placement properly. --- ### Arrows The arrow that points toward the element can have its proportion or shape modified, or be disabled completely. ```js tippy(button, { // default arrow: true, }); ``` --- ### Animations Your tippy can have any type of transition animations. By default, it's a simple `fade` (opacity transition). ```js tippy(button, { // default animation: 'fade', }); ``` #### Extra included animations These animations are included in the package and can be imported separately. {EXTRA_ANIMATIONS.map((animation) => ( ))} #### Material filling effect #### Inertia / slingshot elastic effect Add CSS spring physics to the animation using `transition-timing-function`. {EXTRA_ANIMATIONS.filter((animation) => animation.includes('scale')).map( (animation) => ( ) )} #### CSS keyframe animations Getting more advanced, you can use actual CSS animations (`@keyframes` rules), for example using the `animate.css` package: { requestAnimationFrame(() => { instance.popper.firstElementChild.classList.add( 'rubberBand', 'animated' ); }); }} onHidden={(instance) => { instance.popper.firstElementChild.classList.remove( 'rubberBand', 'animated' ); }} > { requestAnimationFrame(() => { instance.popper.firstElementChild.classList.add('tada', 'animated'); }); }} onHidden={(instance) => { instance.popper.firstElementChild.classList.remove('tada', 'animated'); }} > #### Duration --- ### Themes Your tippy can have custom styling. ```js tippy(button, { theme: 'light', }); ``` #### Included themes These themes are included in the package and can be imported separately. {['light', 'light-border', 'material', 'translucent'].map((theme) => ( ))} #### Custom themes You can apply any CSS to a tippy via a theme. {['gradient', 'retro', 'forest'].map((theme) => ( ))} --- ### Triggers Your tippy can be triggered by a variety of different events, including `click`, `focus`, or any other event: ```js tippy(button, { // default trigger: 'click', }); ``` --- ### Interactivity Your tippy can be interactive, allowing you to hover over and click inside it. ```js tippy(button, { interactive: true, }); ``` --- ### HTML Content Your tippy can contain HTML. Bolded content } > ```js tippy(button, { content: 'Bolded content', allowHTML: true, }); ``` --- ### Delay Your tippy can delay hiding or showing after a trigger. ```js tippy(button, { delay: 500, // ms }); ``` --- ### Follow Cursor Your tippy can follow the mouse cursor and abide by a certain axis. Additionally, the tooltip can follow the cursor until it shows, at which point it will stop following (initial). ```js tippy(button, { followCursor: true, }); ``` --- ### SVGs Your tippy can be placed on SVG nodes, where `followCursor: 'initial'` becomes very useful, since it can be placed directly on the line. --- ### Singleton Use a single tippy for many different reference elements. This allows you to "group" tooltips with a shared timer to improve UX when elements near each other have tooltips with a `delay` prop. Non-singleton tippy with `delay: 500`: Singleton tippy to group each tippy's `delay: 500`: Singleton tippy with a transition: ```js tippy.createSingleton(tippy(buttons), { delay: 500, }); ``` View [singletons in detail](/v6/addons/#singleton). --- ### Nesting A tippy can be nested within another one. This allows you to create a hover menu system. ### Plenty more... The above is not a complete list of features. Tippy is capable of many more things.