Introducing PrimeReact v11-alpha 🎉Discover Now

Tooltip

An unstyled tooltip component with hover/focus triggers, delay management, and group transitions.

Build fully custom tooltips with complete control over layout and styling.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use Tooltip with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Configurable openDelay and closeDelay for timing control
  • Manager enables instant transitions when hovering between adjacent tooltips
  • Interactive popup: hovering the tooltip content keeps it open by default
  • Arrow element with automatic per-side positioning via CSS custom properties

Usage#

import { Tooltip } from 'primereact/tooltip';
<Tooltip.Manager>
    <Tooltip.Root>
        <Tooltip.Trigger></Tooltip.Trigger>
        <Tooltip.Portal>
            <Tooltip.Positioner>
                <Tooltip.Popup>
                    <Tooltip.Arrow />
                </Tooltip.Popup>
            </Tooltip.Positioner>
        </Tooltip.Portal>
    </Tooltip.Root>
</Tooltip.Manager>

Behavior#

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<Tooltip.Trigger as="div">...</Tooltip.Trigger>

Render Function Children#

Sub-components accept a render function as children, providing access to the component instance.

<Tooltip.Trigger>{(instance) => <span>{instance.tooltip?.state.open ? 'Active' : 'Idle'}</span>}</Tooltip.Trigger>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

TooltipManager#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TooltipManagerInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TooltipManagerInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTooltipManagerInstance—
The instance to pass to the component.
ptSafeRecord<TooltipManagerPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TooltipManagerInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
openDelaynumber—
The delay in milliseconds before opening a tooltip.
closeDelaynumber—
The delay in milliseconds before closing a tooltip.
timeoutnumber400
The timeout in milliseconds for the instant phase. If another tooltip opens within this timeout after a tooltip closes, the transition will be instant.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of TooltipManager component.

labeltypedescription
managerTooltipManagerPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the manager's DOM element.

TooltipRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TooltipRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TooltipRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTooltipRootInstance—
The instance to pass to the component.
ptSafeRecord<TooltipRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TooltipRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
openboolean—
Controls the open state of the tooltip.
defaultOpenbooleanfalse
Whether the tooltip is open by default.
disabledbooleanfalse
Whether the tooltip is disabled.
openDelaynumber600
The delay in milliseconds before opening the tooltip on hover.
closeDelaynumber0
The delay in milliseconds before closing the tooltip.
interactivebooleantrue
Whether the tooltip popup is interactive (hoverable). When true, hovering over the popup keeps the tooltip open. When false, the tooltip closes as soon as the pointer leaves the trigger.
onOpenChange(event: TooltipRootChangeEvent) => voidundefined
Callback fired when the tooltip's open state changes.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-instantInstant transition type when applicable

Defines passthrough(pt) options of Tooltip component.

labeltypedescription
rootTooltipRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
triggerTooltipRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the trigger's DOM element.
portalTooltipRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the portal's DOM element.
positionerTooltipRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the positioner's DOM element.
popupTooltipRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the popup's DOM element.
arrowTooltipRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the arrow's DOM element.

TooltipTrigger#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
style(CSSProperties | ((instance?: ButtonInstance) => CSSProperties)) & (CSSProperties | ((instance?: TooltipTriggerInstance) => CSSProperties))—
The style to apply to the component.
className(string | ((instance?: ButtonInstance) => string)) & (string | ((instance?: TooltipTriggerInstance) => string))—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceBaseInstance<SafeRecord<ButtonProps>, unknown, HTMLElement> & { props: SafeRecord<SafeRecord<ButtonProps>>; attrs: Omit<SafeRecord<SafeRecord<ButtonProps>>, string | number | symbol> & Record<PropertyKey, unknown> } & { state: SafeRecord; $computedSetup: SafeRecord } & ButtonExposes & Record<PropertyKey, unknown> & useComponentPTReturnType & useComponentStyleReturnType & BaseInstance<SafeRecord<TooltipTriggerProps>, unknown, HTMLElement> & { props: SafeRecord<SafeRecord<TooltipTriggerProps>>; attrs: Omit<SafeRecord<SafeRecord<TooltipTriggerProps>>, string | number | symbol> & Record<PropertyKey, unknown> } & { state: SafeRecord; $computedSetup: SafeRecord } & TooltipTriggerExposes—
The instance to pass to the component.
ptButtonPassThrough & Record<PropertyKey, unknown> & TooltipTriggerPassThrough—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: ButtonInstance) => ReactNode & (instance: TooltipTriggerInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
size"small" | "large" | "normal"—
Size of the Button.
severitystring & {} | "secondary" | "info" | "success" | "warn" | "danger" | "contrast" | "help"—
Severity type of the Button.
variant"link" | "text" | "outlined"—
Variant of the Button.
plainboolean—
Whether to show the Button with a plain style.
roundedboolean—
Whether to show the Button with a rounded style.
raisedboolean—
Whether to show the Button with a raised style.
iconOnlyboolean—
Whether to show the Button with a borderless style.
fluidboolean—
Whether to show the Button with a fluid width.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-popup-openPresent when tooltip is open

Defines passthrough(pt) options of TooltipTrigger component.

labeltypedescription
rootTooltipTriggerPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

TooltipPortal#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
style(CSSProperties | ((instance?: PortalInstance) => CSSProperties)) & (CSSProperties | ((instance?: TooltipPortalInstance) => CSSProperties))—
The style to apply to the component.
className(string | ((instance?: PortalInstance) => string)) & (string | ((instance?: TooltipPortalInstance) => string))—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceBaseInstance<SafeRecord<PortalProps>, unknown, HTMLElement> & { props: SafeRecord<SafeRecord<PortalProps>>; attrs: Omit<SafeRecord<SafeRecord<PortalProps>>, string | number | symbol> & Record<PropertyKey, unknown> } & { state: SafeRecord; $computedSetup: SafeRecord } & PortalExposes & Record<PropertyKey, unknown> & useComponentPTReturnType & useComponentStyleReturnType & BaseInstance<SafeRecord<TooltipPortalProps>, unknown, HTMLElement> & { props: SafeRecord<SafeRecord<TooltipPortalProps>>; attrs: Omit<SafeRecord<SafeRecord<TooltipPortalProps>>, string | number | symbol> & Record<PropertyKey, unknown> } & { state: SafeRecord; $computedSetup: SafeRecord } & TooltipPortalExposes—
The instance to pass to the component.
ptPortalPassThrough & Record<PropertyKey, unknown> & TooltipPortalPassThrough—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: PortalInstance) => ReactNode & (instance: TooltipPortalInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
onMounted() => void—
Callback function to invoke when the portal is mounted.
onUnmounted() => void—
Callback function to invoke when the portal is unmounted.
elementHTMLElement | ReactNode—
The element to be rendered as the portal.
elementRefRefObject<HTMLElement>—
The element reference to be rendered as the portal.
appendTostring | HTMLElement | ((instance: PortalInstance) => HTMLElement)'body'
The DOM element where the portal should be appended to.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.

Defines passthrough(pt) options of TooltipPortal component.

labeltypedescription
rootTooltipPortalPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TooltipPositioner#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TooltipPositionerInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TooltipPositionerInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTooltipPositionerInstance—
The instance to pass to the component.
ptSafeRecord<TooltipPositionerPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TooltipPositionerInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
sideSideType—
The side of the positioner.
alignAlignType—
The align of the positioner.
sideOffsetnumber—
The side offset of the positioner.
alignOffsetnumber—
The align offset of the positioner.
flipboolean—
Whether to flip the positioner.
shiftboolean—
Whether to shift the positioner.
hideWhenDetachedboolean—
Whether to hide the positioner when detached.
strategy"fixed" | "absolute"'fixed'
The positioning strategy.
boundaryHTMLElement—
The boundary element that constrains the positioner placement. Used in JS fallback mode only; CSS Anchor mode uses the containing block.
anchorHTMLElement—
The anchor element.
contentHTMLDivElement—
The content element.
arrowHTMLDivElement—
The arrow element.
autoZIndexbooleantrue
Whether to automatically manage layering.
baseZIndexnumber0
Base zIndex value to use in layering.
onPlacementChange(placement: { side: SideType; align: AlignType }) => void—
Callback invoked when the actual placement changes due to flip or shift.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-openPresent when tooltip is open
data-side"top" | "bottom" | "left" | "right" — placement
data-align"start" | "center" | "end" — alignment

CSS Custom Properties

The positioner element exposes CSS custom properties for layout and transform control.

CSS VariableDescription
--available-heightAvailable vertical space in pixels
--available-widthAvailable horizontal space in pixels
--transform-originComputed transform origin for animations
--positioner-anchor-widthWidth of the anchor/trigger element

Defines passthrough(pt) options of TooltipPositioner component.

labeltypedescription
rootTooltipPositionerPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

TooltipPopup#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TooltipPopupInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TooltipPopupInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTooltipPopupInstance—
The instance to pass to the component.
ptSafeRecord<TooltipPopupPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TooltipPopupInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-openPresent when tooltip is visible
data-instantPresent when an instant transition occurs
data-instant-type'delay', 'focus', or 'dismiss'

Defines passthrough(pt) options of TooltipPopup component.

labeltypedescription
rootTooltipPopupPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

TooltipArrow#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: TooltipArrowInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: TooltipArrowInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceTooltipArrowInstance—
The instance to pass to the component.
ptSafeRecord<TooltipArrowPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: TooltipArrowInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-openPresent when tooltip is visible
data-instantInstant transition type when applicable
data-side"top" | "bottom" | "left" | "right" — placement
data-align"start" | "center" | "end" — alignment

CSS Custom Properties

The arrow element exposes CSS custom properties for dynamic positioning:

CSS VariableDescription
--placer-arrow-xHorizontal offset of arrow
--placer-arrow-yVertical offset of arrow
--placer-arrow-leftLeft position of arrow element
--placer-arrow-topTop position of arrow element

Defines passthrough(pt) options of TooltipArrow component.

labeltypedescription
rootTooltipArrowPassThroughType<HTMLAttributes<HTMLButtonElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

Tooltip popup content should be descriptive and associated with a meaningful trigger label.

Keyboard Support#

KeyFunction
tabFocuses the trigger, opening the tooltip with instant transition.
escapeCloses the tooltip and returns focus to the trigger.