A React tooltip component from Radix UI Primitives, part of an open-source UI component library for building high-quality, accessible design systems and web apps
npx @tessl/cli install tessl/npm-radix-ui--react-tooltip@1.2.0Radix UI React Tooltip provides a comprehensive, accessible tooltip component system for React applications. It features sophisticated hover behavior, keyboard navigation, portal rendering, and full ARIA compliance through a compound component pattern.
npm install @radix-ui/react-tooltipimport {
createTooltipScope,
TooltipProvider,
Tooltip,
TooltipTrigger,
TooltipPortal,
TooltipContent,
TooltipArrow,
} from "@radix-ui/react-tooltip";Alternative short aliases:
import {
Provider,
Root,
Trigger,
Portal,
Content,
Arrow,
} from "@radix-ui/react-tooltip";For TypeScript types:
import type {
TooltipProviderProps,
TooltipProps,
TooltipTriggerProps,
TooltipPortalProps,
TooltipContentProps,
TooltipArrowProps,
} from "@radix-ui/react-tooltip";import {
TooltipProvider,
Tooltip,
TooltipTrigger,
TooltipPortal,
TooltipContent,
TooltipArrow,
} from "@radix-ui/react-tooltip";
function MyComponent() {
return (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<button>Hover me</button>
</TooltipTrigger>
<TooltipPortal>
<TooltipContent side="top">
This is a tooltip!
<TooltipArrow />
</TooltipContent>
</TooltipPortal>
</Tooltip>
</TooltipProvider>
);
}Radix UI React Tooltip uses a compound component pattern with hierarchical structure:
TooltipProvider manages global tooltip behavior and timingTooltip manages individual tooltip state and controlsTooltipTrigger handles user interactions (hover, focus, keyboard)TooltipPortal renders content outside normal DOM flowTooltipContent provides the visible tooltip with positioning and accessibilityTooltipArrow adds directional pointer to tooltipKey design patterns:
Global tooltip provider that manages timing, delays, and hover behavior across all tooltips in your application.
interface TooltipProviderProps {
children: React.ReactNode;
delayDuration?: number;
skipDelayDuration?: number;
disableHoverableContent?: boolean;
}
const TooltipProvider: React.FC<TooltipProviderProps>;Individual tooltip instance that manages open/closed state, timing, and accessibility features.
interface TooltipProps {
children?: React.ReactNode;
open?: boolean;
defaultOpen?: boolean;
onOpenChange?: (open: boolean) => void;
delayDuration?: number;
disableHoverableContent?: boolean;
}
const Tooltip: React.FC<TooltipProps>;Interactive trigger element that responds to hover, focus, and keyboard events to show/hide tooltips.
type TooltipTriggerElement = React.ComponentRef<"button">;
interface TooltipTriggerProps extends React.ComponentPropsWithoutRef<"button"> {
asChild?: boolean;
}
const TooltipTrigger: React.forwardRef<TooltipTriggerElement, TooltipTriggerProps>;Portal component for rendering tooltip content outside the normal DOM hierarchy, plus the main content component with positioning and accessibility features.
interface TooltipPortalProps {
children?: React.ReactNode;
container?: HTMLElement;
forceMount?: true;
}
interface TooltipContentProps {
forceMount?: true;
side?: "top" | "right" | "bottom" | "left";
sideOffset?: number;
align?: "start" | "center" | "end";
alignOffset?: number;
avoidCollisions?: boolean;
collisionBoundary?: Element | Element[];
collisionPadding?: number | Partial<Record<"top" | "right" | "bottom" | "left", number>>;
arrowPadding?: number;
sticky?: "partial" | "always";
hideWhenDetached?: boolean;
'aria-label'?: string;
onEscapeKeyDown?: (event: KeyboardEvent) => void;
onPointerDownOutside?: (event: CustomEvent) => void;
}
const TooltipPortal: React.FC<TooltipPortalProps>;
const TooltipContent: React.forwardRef<HTMLDivElement, TooltipContentProps>;Portal Rendering and Content Display
Optional arrow/pointer component that visually connects the tooltip to its trigger.
interface TooltipArrowProps {
width?: number;
height?: number;
offset?: number;
}
const TooltipArrow: React.forwardRef<SVGSVGElement, TooltipArrowProps>;Context scoping utilities for advanced tooltip customization and nesting scenarios.
function createTooltipScope(): Scope;type TooltipProviderProps = {
children: React.ReactNode;
delayDuration?: number;
skipDelayDuration?: number;
disableHoverableContent?: boolean;
};
type TooltipProps = {
children?: React.ReactNode;
open?: boolean;
defaultOpen?: boolean;
onOpenChange?: (open: boolean) => void;
delayDuration?: number;
disableHoverableContent?: boolean;
};
type TooltipTriggerProps = React.ComponentPropsWithoutRef<"button"> & {
asChild?: boolean;
};
type TooltipPortalProps = {
children?: React.ReactNode;
container?: HTMLElement;
forceMount?: true;
};
type TooltipContentProps = React.ComponentPropsWithoutRef<"div"> & {
forceMount?: true;
side?: "top" | "right" | "bottom" | "left";
sideOffset?: number;
align?: "start" | "center" | "end";
alignOffset?: number;
avoidCollisions?: boolean;
collisionBoundary?: Element | Element[];
collisionPadding?: number | Partial<Record<"top" | "right" | "bottom" | "left", number>>;
arrowPadding?: number;
sticky?: "partial" | "always";
hideWhenDetached?: boolean;
'aria-label'?: string;
onEscapeKeyDown?: (event: KeyboardEvent) => void;
onPointerDownOutside?: (event: CustomEvent) => void;
};
type TooltipArrowProps = React.ComponentPropsWithoutRef<"svg"> & {
width?: number;
height?: number;
offset?: number;
};