Skip to main content
Version: latest
Works everywhere

Tooltip works in both server and client environments. Always use the standard import (e.g. @prokodo/ui/tooltip) — the library detects the runtime automatically.

Tooltip

Tooltip displays a small informational popup anchored to a trigger element. It activates on hover and focus (keyboard accessible) and supports all four placement directions.

Live demo →

Overview

import { Tooltip } from "@prokodo/ui/tooltip"
;<Tooltip content="This action cannot be undone" placement="top">
<button>Delete</button>
</Tooltip>

Import

import { Tooltip } from "@prokodo/ui/tooltip"

CSS:

import "@prokodo/ui/tooltip.css"

Props

PropTypeDefaultRequiredDescription
childrenReactElementTrigger element — must be a single element that forwards a ref.
contentReactNodeTooltip content.
placement"top" | "bottom" | "left" | "right""top"Preferred placement relative to the trigger.
anchor"element" | "pointer""element"Anchor mode: "element" centers on trigger; "pointer" follows cursor.
color"default" | "success" | "error" | "warning" | "info""default"Visual color variant of the bubble.
idstringStable id for aria-describedby.
disabledbooleanfalseDisable tooltip entirely.
openbooleanControlled open state.
defaultOpenbooleanfalseUncontrolled initial open state.
delaynumber200Hover/focus open delay in ms.
closeDelaynumberClose delay in ms.
openOnHoverbooleantrueOpen on hover.
openOnFocusbooleantrueOpen on focus.
preventOverflowbooleantrueClamp tooltip into the viewport.
portalbooleantrueRender bubble in a portal (recommended).
zIndexnumberZ-index for the portal bubble.
offsetnumberPixel gap between trigger and bubble.
onOpenChange(open: boolean) => voidCalled when open state changes.
tooltipClassNamestringCSS class on the tooltip bubble element.
triggerClassNamestringCSS class on the trigger element.
classNamestringCSS class on the root wrapper element.

See src/components/tooltip/Tooltip.model.ts for the full TooltipProps type.


Design Tokens

Customise via CSS custom properties on :root or a scoped ancestor.

TokenDefaultDescription
--pk-tooltip-bgcolor-mix(… fg 92%, surface)Default background (dark inverted)
--pk-tooltip-fgvar(--pk-color-surface)Default text color
--pk-tooltip-bordercolor-mix(… surface 12%)Default accent border
--pk-tooltip-shadowvar(--pk-shadow-lg)Default box-shadow
--pk-tooltip-radiusvar(--pk-radius-sm)Border-radius
--pk-tooltip-z2147483647z-index
--pk-tooltip-success-bgcolor-mix(… success 12%, surface)Success tinted background
--pk-tooltip-success-fgvar(--pk-color-fg)Success text color
--pk-tooltip-success-bordercolor-mix(… success 35%)Success accent border
--pk-tooltip-success-shadow0 4px 16px color-mix(… success 18%)Success ambient glow
--pk-tooltip-error-bgcolor-mix(… error 12%, surface)Error tinted background
--pk-tooltip-error-fgvar(--pk-color-fg)Error text color
--pk-tooltip-error-bordercolor-mix(… error 35%)Error accent border
--pk-tooltip-error-shadow0 4px 16px color-mix(… error 18%)Error ambient glow
--pk-tooltip-warning-bgcolor-mix(… warning 12%, surface)Warning tinted background
--pk-tooltip-warning-fgvar(--pk-color-fg)Warning text color
--pk-tooltip-warning-bordercolor-mix(… warning 35%)Warning accent border
--pk-tooltip-warning-shadow0 4px 16px color-mix(… warning 18%)Warning ambient glow
--pk-tooltip-info-bgcolor-mix(… fg 8%, surface)Info tinted background
--pk-tooltip-info-fgvar(--pk-color-fg)Info text color
--pk-tooltip-info-bordercolor-mix(… fg 20%)Info accent border
--pk-tooltip-info-shadowvar(--pk-shadow-md)Info box-shadow

AIC Note

Use the standard import path in application code:

import { Tooltip } from "@prokodo/ui/tooltip"

No separate /client or /lazy import selection is required in consumer code.

AIC components also support a priority flag for critical above-the-fold elements. This is most visible on Image (native preloading via <link rel="preload"> for above-the-fold content).


WCAG 2.2 Status

CriterionNameStatusNote
1.3.1Info and Relationships (A)✅ FulfilledSemantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA.
1.4.3Contrast (Minimum) (AA)🔍 Manual reviewText must have a contrast ratio of at least 4.5:1 (3:1 for large text). Verify against the final product theme.
2.4.7Focus Visible (AA)🔍 Manual reviewA visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme.
4.1.2Name, Role, Value (A)✅ FulfilledName, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA.

Test coverage: 2 jest-axe assertion(s) across 5 test file(s) · 3 ARIA attribute occurrence(s) in source scan. Criteria marked 🔍 require manual verification in the final product integration and theme context.

Storybook

👉 Open Tooltip in Storybook


Source

src/components/tooltip/Tooltip.model.ts