Skip to content

Tooltip Primitive

Types Primitives Hooks Primitives Slot Primitives Portal Primitives

@radix-ui/react-tooltip


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 @radix-ui/react-tooltip

Terminal window
npx expo install @radix-ui/react-tooltip

Copy/paste the following code for web to ~/components/primitives/tooltip/tooltip.web.tsx

Copy/paste the following code for native to ~/components/primitives/tooltip/tooltip.tsx

Copy/paste the following code for types to ~/components/primitives/tooltip/types.ts

Copy/paste the following code for exporting to ~/components/primitives/tooltip/index.ts

Usage

import * as TooltipPrimitive from '~/components/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)
openboolean(optional)
onOpenChange(value: boolean) => void(optional)
defaultOpenboolean(optional)
delayDurationnumberWeb Only - defaults to 700 (optional)
skipDelayDurationnumberWeb Only - defaults to 300 (optional)
disableHoverableContentboolean(optional)

Trigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

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)