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.
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
Copy/paste the following code for native to ~/components/primitives/tooltip/index.tsx
Copy/paste the following code for types to ~/components/primitives/tooltip/types.ts
Usage
Props
Root
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
onOpenChange | (value: boolean) => void | (optional) |
delayDuration | number | Web Only - defaults to 700 (optional) |
skipDelayDuration | number | Web Only - defaults to 300 (optional) |
disableHoverableContent | boolean | (optional) |
Trigger
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
TYPE: TooltipTriggerRef
Methods | args | Note |
---|---|---|
open | opens the tooltip | |
close | closes the tooltip |
Overlay
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
forceMount | true | undefined; | (optional) |
closeOnPress | boolean | (optional) |
Portal
Prop | Type | Note |
---|---|---|
children* | React.ReactNode | |
forceMount | true | undefined | (optional) |
hostName | string | Web Only (optional) |
container | HTMLElement | null | undefined | Web Only (optional) |
Content
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
forceMount | true | undefined | (optional) |
alignOffset | number | (optional) |
insets | Insets | (optional) |
avoidCollisions | boolean | (optional) |
align | start | center | end | (optional) |
side | top | bottom | left | right | left and right are web only (optional) |
sideOffset | number | (optional) |
disablePositioningStyle | boolean | Native Only (optional) |
collisionBoundary | Element | null | Array<Element | null> | Web Only (optional) |
sticky | partial | always | Web Only (optional) |
hideWhenDetached | boolean | Web Only (optional) |
onEscapeKeyDown | (ev: Event) => void | Web Only (optional) |
onPointerDownOutside | (ev: Event) => void | Web Only (optional) |