Skip to content

Tooltip Primitive

A pop-up presenting relevant information pertaining to an element whenever the element gains keyboard focus or when the mouse hovers over it.

Installation

Install the component via your command line.

Terminal window
npx expo install @rn-primitives/tooltip

Usage

import * as TooltipPrimitive from '@rn-primitives/tooltip';
import { Platform, Text } from 'react-native';
function Example() {
return (
<TooltipPrimitive.Root>
<TooltipPrimitive.Trigger>
<Text>{Platform.OS === 'web' ? "Hover me" : "Press me"}</Text>
</TooltipPrimitive.Trigger>
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content>
<Text>Tooltip Content</Text>
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
</TooltipPrimitive.Root>
);
}

Props

Root

Extends View props

PropTypeNote
asChildboolean(optional)
onOpenChange(value: boolean) => void(optional)
delayDurationnumberWeb Only - defaults to 700 (optional)
skipDelayDurationnumberWeb Only - defaults to 300 (optional)
disableHoverableContentboolean(optional)

Trigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

TYPE: TooltipTriggerRef

MethodsargsNote
openopens the tooltip
closecloses the tooltip

Overlay

Extends Pressable props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined;(optional)
closeOnPressboolean(optional)

Portal

PropTypeNote
children*React.ReactNode
forceMounttrue | undefined(optional)
hostNamestringWeb Only (optional)
containerHTMLElement | null | undefinedWeb Only (optional)

Content

Extends View props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined(optional)
alignOffsetnumber(optional)
insetsInsets(optional)
avoidCollisionsboolean(optional)
align’start’ | ‘center’ | ‘end’(optional)
side’top’ | ‘bottom’(optional)
sideOffsetnumber(optional)
disablePositioningStylebooleanNative Only (optional)
collisionBoundaryElement | null | Array<Element | null>Web Only (optional)
sticky’partial’ | ‘always’Web Only (optional)
hideWhenDetachedbooleanWeb Only (optional)
onEscapeKeyDown(ev: Event) => voidWeb Only (optional)
onPointerDownOutside(ev: Event) => voidWeb Only (optional)