Tooltip

Tooltip is a moduix React component built on Ark UI that shows a small, styled popup with descriptive text when a trigger element is hovered or focused. It renders through the moduix overlay portal and ships with animated open and close motion.

Tooltip
LIVE · running in a sandboxed iframe
Installed with shadcn add · 1 workaround · theme from registry.json
  • installed base item https://moduix.dev/r/react/init.json (registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add @moduix-react/tooltip

Requires @moduix-react in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { Tooltip, TooltipTrigger, TooltipPositioner, TooltipContent, TooltipArrow, TooltipArrowTip } from '@components/ui/tooltip'; export default function Example() { return (<Tooltip openDelay={300}><TooltipTrigger>Hover me</TooltipTrigger><TooltipBody>Helpful hint</TooltipBody></Tooltip>); }
  • Adding a short hint or label that explains an icon-only button, control, or abbreviation on hover or keyboard focus.
  • Showing supplementary, non-essential help text that should not block the user or require interaction.
  • Explaining why a control is disabled by wrapping it with TooltipDisabledTrigger so it still receives focus and hover.
  • Displaying a tooltip with a directional arrow for a more visually anchored hint next to a trigger.

Examples

Icon button with hint

A basic tooltip describing an icon-only button. The Tooltip root wraps the trigger and body, and TooltipBody renders the positioner and content together.

icon-button-with-hint.tsx
import { Tooltip, TooltipTrigger, TooltipBody } from '@components/ui/tooltip'; export default function IconHint() { return (<Tooltip><TooltipTrigger aria-label='Delete item'>X</TooltipTrigger><TooltipBody>Delete item</TooltipBody></Tooltip>); }

Custom trigger with asChild and arrow

Uses asChild to merge tooltip behavior into an existing button element and adds a TooltipArrow with the default arrow tip.

custom-trigger-with-aschild-and-arrow.tsx
import { Tooltip, TooltipTrigger, TooltipPositioner, TooltipContent, TooltipArrow } from '@components/ui/tooltip'; export default function ArrowHint() { return (<Tooltip><TooltipTrigger asChild><button type='button'>Save</button></TooltipTrigger><TooltipPositioner><TooltipContent>Save changes<TooltipArrow /></TooltipContent></TooltipPositioner></Tooltip>); }

Disabled control explanation

Wraps a disabled button in TooltipDisabledTrigger so the reason is still reachable by hover and keyboard focus.

disabled-control-explanation.tsx
import { Tooltip, TooltipDisabledTrigger, TooltipBody } from '@components/ui/tooltip'; export default function DisabledHint() { return (<Tooltip><TooltipDisabledTrigger><button type='button' disabled>Submit</button></TooltipDisabledTrigger><TooltipBody>Complete the form to submit</TooltipBody></Tooltip>); }

Externally controlled tooltip

Uses TooltipRootProvider with a value from useTooltip for programmatic control of the tooltip state.

externally-controlled-tooltip.tsx
import { useTooltip, TooltipRootProvider, TooltipTrigger, TooltipBody } from '@components/ui/tooltip'; export default function ControlledHint() { const tooltip = useTooltip(); return (<TooltipRootProvider value={tooltip}><TooltipTrigger>Info</TooltipTrigger><TooltipBody>More information</TooltipBody></TooltipRootProvider>); }

API reference

PropTypeDefaultDescription
lazyMountbooleantrueDefers mounting tooltip content until first opened. Forwarded to the Ark Tooltip root (Tooltip and TooltipRootProvider).
unmountOnExitbooleantrueUnmounts tooltip content after the close animation completes. Forwarded to the Ark Tooltip root (Tooltip and TooltipRootProvider).
portalledOverlayPortalProps['portalled']—Controls whether the tooltip is rendered through the moduix overlay portal. Passed to OverlayPortalProvider on Tooltip and TooltipRootProvider.
portalRefOverlayPortalProps['portalRef']—Ref to the element that the overlay portal mounts into. Passed to OverlayPortalProvider on Tooltip and TooltipRootProvider.
...props (Root)ComponentProps<typeof TooltipPrimitive.Root>—All remaining Ark UI Tooltip root props, such as openDelay, closeDelay, positioning, and open state controls, spread onto Tooltip.
...props (RootProvider)ComponentProps<typeof TooltipPrimitive.RootProvider>—All remaining Ark UI Tooltip RootProvider props, including the value returned by useTooltip, spread onto TooltipRootProvider.
asChildboolean—On TooltipTrigger, merges the trigger behavior and styles onto the single child element instead of rendering a button. When true, the default trigger class is not applied.
classNamestring—Additional class name merged with the component's default class via clsx on TooltipTrigger, TooltipDisabledTrigger, TooltipPositioner, TooltipContent, TooltipArrow, and TooltipArrowTip.
tabIndexnumber0Keyboard focus index for TooltipDisabledTrigger's span wrapper, so disabled controls remain focusable.
children (TooltipArrow)ReactNode<TooltipArrowTip />Custom arrow content for TooltipArrow. Defaults to the TooltipArrowTip element when omitted.
refRef—Forwarded ref on TooltipTrigger, TooltipDisabledTrigger (HTMLSpanElement), TooltipPositioner, TooltipContent, TooltipArrow, and TooltipArrowTip.

Accessibility

  • Built on Ark UI Tooltip, which manages the trigger-to-content relationship and ARIA attributes such as aria-describedby for screen readers.
  • Tooltip text is supplementary; do not place essential information or interactive controls only inside a tooltip, because it may be missed by keyboard and touch users.
  • Icon-only triggers still need an accessible name, for example via aria-label on the trigger, since the tooltip content is not a substitute for a label.
  • TooltipDisabledTrigger uses tabIndex 0 by default so keyboard users can focus a disabled control and read the explanation.
  • The trigger shows a visible focus-visible outline using the moduix ring color, and the popup is dismissed by the Ark UI default Escape handling.
  • Open and close animations are disabled under prefers-reduced-motion: reduce, and the trigger transition is removed.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Tooltip" component (moduix-react/tooltip) from its shadcn registry.1. Install it with: npx shadcn@latest add @moduix-react/tooltip2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: lazyMount, unmountOnExit, portalled, portalRef, ...props (Root), ...props (RootProvider), asChild, className, tabIndex, children (TooltipArrow), ref.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { Tooltip, TooltipTrigger, TooltipPositioner, TooltipContent, TooltipArrow, TooltipArrowTip } from '@components/ui/tooltip'; export default function Example() { return (<Tooltip openDelay={300}><TooltipTrigger>Hover me</TooltipTrigger><TooltipBody>Helpful hint</TooltipBody></Tooltip>); }```

Files & dependencies

  • src/components/tooltip/Tooltip.tsx→ @components/ui/tooltip/Tooltip.tsx
  • src/components/tooltip/Tooltip.module.css→ @components/ui/tooltip/Tooltip.module.css
  • src/components/tooltip/index.ts→ @components/ui/tooltip/index.ts
dependencies@ark-ui/react@^5.40.0clsx@^2.1.1
registryDependencies@moduix-react/foundation@moduix-react/overlay-portal

Looks similar, elsewhere