Skip to main content

Options

All available data attributes for the anchor element and props for the tooltip component.

Data attributes

import { Tooltip } from 'react-tooltip';

<a
data-tooltip-id="my-tooltip"
data-tooltip-content="Hello world!"
>
◕‿‿◕
</a>
<Tooltip id="my-tooltip" />
◕‿‿◕

Available attributes

nametyperequireddefaultvaluesdescription
data-tooltip-idstringfalseThe id set on the tooltip element (same as V4's data-for)
data-tooltip-contentstringfalseContent to be displayed in the tooltip (html is priorized over content)
data-tooltip-htmlstringfalseHTML content to be displayed in tooltip
data-tooltip-placestringfalsetoptop top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-endPosition relative to the anchor element where the tooltip will be rendered (if possible)
data-tooltip-offsetnumberfalse10any numberSpace between the tooltip element and anchor element (arrow not included in the calculation)
data-tooltip-variantstringfalsedarkdark light success warning error infoChange the tooltip style with default presets
data-tooltip-wrapperstringfalsedivdiv spanElement wrapper for the tooltip container, can be div, span, p or any valid HTML tag
data-tooltip-eventsstringfalsehoverhover click hover clickEvents to watch for when handling the tooltip state
DEPRECATED
Use openOnClick tooltip prop instead
data-tooltip-position-strategystringfalseabsoluteabsolute fixedThe position strategy used for the tooltip. Set to fixed if you run into issues with overflow: hidden on the tooltip parent container
data-tooltip-delay-shownumberfalseany numberThe delay (in ms) before showing the tooltip
data-tooltip-delay-hidenumberfalseany numberThe delay (in ms) before hiding the tooltip
data-tooltip-floatbooleanfalsefalsetrue falseTooltip will follow the mouse position when it moves inside the anchor element (same as V4's effect="float")
data-tooltip-hiddenbooleanfalsefalsetrue falseTooltip will not be shown
data-tooltip-class-namestringfalseClassnames for the tooltip container

Props

import { Tooltip } from 'react-tooltip';

<a id="my-anchor-element">◕‿‿◕</a>
<Tooltip
anchorSelect="#my-anchor-element"
content="Hello world!"
/>
◕‿‿◕

Available props

nametyperequireddefaultvaluesdescription
refTooltip referencenoReact.useRefReference object which exposes internal state, and some methods for manually controlling the tooltip. See the examples.
classNamestringnoClass name to customize tooltip element. You can also use the default class react-tooltip which is set internally
classNameArrowstringnoClass name to customize tooltip arrow element. You can also use the default class react-tooltip-arrow which is set internally
contentstringnoContent to be displayed in tooltip (html prop is priorized over content)
htmlstringnoHTML content to be displayed in tooltip
DEPRECATED
Use children or render instead
renderfunctionnoA function which receives a ref to the currently active anchor element and returns the content for the tooltip. Check the examples
placestringnotoptop top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-endPosition relative to the anchor element where the tooltip will be rendered (if possible)
offsetnumberno10any numberSpace between the tooltip element and anchor element (arrow not included in calculation)
idstringnoany stringThe tooltip id. Must be set when using data-tooltip-id on the anchor element
anchorIdstringnoany stringThe id for the anchor element for the tooltip
DEPRECATED
Use data-tooltip-id or anchorSelect instead
anchorSelectCSS selectornoany valid CSS selectorThe selector for the anchor elements. Check the examples for more details
variantstringnodarkdark light success warning error infoChange the tooltip style with default presets
wrapperHTML tagnodivdiv span p ...Element wrapper for the tooltip container, can be div, span, p or any valid HTML tag
childrenReact nodenoundefinedvalid React childrenThe tooltip children have lower priority compared to the content prop and the data-tooltip-content attribute. Useful for setting default content
eventsstring[]nohoverhover clickEvents to watch for when handling the tooltip state
DEPRECATED
Use openOnClick tooltip prop instead
openOnClickbooleannofalsetrue falseWhen enabled, the tooltip will open on click instead of on hover. Use openEvents, closeEvents, and globalCloseEvents for more customization
positionStrategystringnoabsoluteabsolute fixedThe position strategy used for the tooltip. Set to fixed if you run into issues with overflow: hidden on the tooltip parent container
delayShownumbernoany numberThe delay (in ms) before showing the tooltip
delayHidenumbernoany numberThe delay (in ms) before hiding the tooltip
floatbooleannofalsetrue falseTooltip will follow the mouse position when it moves inside the anchor element (same as V4's effect="float")
hiddenbooleannofalsetrue falseTooltip will not be shown
noArrowbooleannofalsetrue falseTooltip arrow will not be shown
clickablebooleannofalsetrue falseAllow interaction with elements inside the tooltip. Useful when using buttons and inputs
closeOnEscbooleannofalsetrue falsePressing escape key will close the tooltip
DEPRECATED
Use globalCloseEvents instead.
closeOnScrollbooleannofalsetrue falseScrolling will close the tooltip
DEPRECATED
Use globalCloseEvents instead.
closeOnResizebooleannofalsetrue falseResizing the window will close the tooltip
DEPRECATED
Use globalCloseEvents instead.
openEventsRecord<string, boolean>nomouseover focusmouseover focus mouseenter click dblclick mousedownEvents to be listened on the anchor elements to open the tooltip
closeEventsRecord<string, boolean>nomouseout blurmouseout blur mouseleave click dblclick mouseupEvents to be listened on the anchor elements to close the tooltip
globalCloseEventsRecord<string, boolean>noescape scroll resize clickOutsideAnchorGlobal events to be listened to close the tooltip (escape closes on pressing ESC, clickOutsideAnchor is useful with click events on openEvents)
imperativeModeOnlybooleannofalsetrue falseWhen enabled, default tooltip behavior is disabled. Check the examples for more details
styleCSSPropertiesnoa CSS style objectAdd inline styles directly to the tooltip
position{ x: number; y: number }noany number value for both x and yOverride the tooltip position on the DOM
isOpenbooleannotrue falseThe tooltip can be controlled or uncontrolled, this attribute can be used to handle show and hide tooltip outside tooltip (can be used without setIsOpen)
defaultIsOpenbooleannofalsetrue falseIt determines the initial visibility of the tooltip. If true, the tooltip is shown by default, if false or not provided then it's in hidden state by default.
setIsOpenfunctionnoThe tooltip can be controlled or uncontrolled, this attribute can be used to handle show and hide tooltip outside tooltip
afterShowfunctionnoA function to be called after the tooltip is shown
afterHidefunctionnoA function to be called after the tooltip is hidden
disableTooltipfunctionnoA function that takes a ref to each anchor element and returns a boolean indicating whether to hide the tooltip for that specific anchor.
middlewaresMiddleware[]noarray of valid floating-ui middlewaresAllows for advanced customization. Check the floating-ui docs for more information
borderCSS bordernoa CSS border styleChange the style of the tooltip border (including the arrow)
opacityCSS opacityno0.9a CSS opacity valueChange the opacity of the tooltip
arrowColorCSS colornoa CSS background colorChange color of the tooltip arrow
disableStyleInjectionboolean or 'core'nofalsetrue false 'core'Whether to disable automatic style injection. Do not set dynamically. Check the styling page for more details
roleReact.AriaRolenotooltip'tooltip' 'dialog'Set ARIA role, either tooltip or dialog if the tooltip should contain focusable elements