Todae

Todae

useTooltip

useTooltip is the open machine behind Tooltip. Spread getTriggerProps on the trigger and getTooltipProps on Tooltip.Root, which is tip chrome only. Hover waits showDelay, or else the tooltip.delay.show token (300ms by default), focus from keys opens at once, focus that follows a press, such as a click's, opens no tip, and on a coarse pointer only keyboard focus opens one. While a hover tip is open, and for the next tip's skipDelay milliseconds after the last hover tip closes, that next hover tip opens at once. skipDelay defaults to 300, and a skipDelay of 0 turns skipping off, so that tip always waits. Focus does not start that window. Pass interactive: true for a tip with links: it becomes a non-modal tip dialog that Tab can move into, and Tooltip.Root then needs exactly one of aria-label or aria-labelledby.

On this page

A non-button trigger, such as a relative time that tips its exact time, uses the hook directly. Mark a non-tabbable trigger with tabIndex={0}. A tap opens no tip, so keep the tip a hint: a +N that stands for hidden chips is ChipList's +N button, which opens a popover with them. Button.Root already tips its own label, so set tooltip={false} on it when the hook owns the tip.

import { formatRelativeTime, Tooltip, useTooltip } from '@tounsoo/todae';

export default function TooltipTime({ locale }: { locale: string }) {
  const tooltip = useTooltip();
  // A fixed clock, so the demo reads the same on every visit; a product passes its own.
  const now = Temporal.ZonedDateTime.from('2026-10-22T09:30:00+09:00[Asia/Seoul]');
  const edited = now.subtract({ hours: 5 });
  return (
    <p>
      Edited{' '}
      <time {...tooltip.getTriggerProps({ tabIndex: 0 })} lang={locale} dateTime={edited.toInstant().toString()}>
        {formatRelativeTime(edited, now, { locale })}
      </time>
      {/* The exact time names its zone, since it is the clock's, not the reader's. */}
      <Tooltip.Root {...tooltip.getTooltipProps()} lang={locale}>
        {new Intl.DateTimeFormat(locale, {
          year: 'numeric',
          month: 'short',
          day: 'numeric',
          hour: 'numeric',
          minute: '2-digit',
          timeZone: edited.timeZoneId,
          timeZoneName: 'short',
        }).format(edited.epochMilliseconds)}
      </Tooltip.Root>
    </p>
  );
}

Edited

Accessible composition

Todae handles: getTriggerProps adds pointer and focus handlers and, while the tip is open, adds the tip's id to the trigger's aria-describedby, after any ids you passed. Focus from keys opens the tip at once, so keyboard users get it too. Focus that follows a press, such as a click's or what a menu closed by a click hands back, opens no tip; the pointer has the hover tip. Tooltip.Root adds role="tooltip", or role="dialog" with interactive: true. Escape closes the tip, and from inside an interactive one sends focus back to the trigger.

You supply: A trigger that takes focus. The getter adds no tabIndex or role, so give a wrap that is not tabbable tabIndex={0}, as above. A name for the trigger itself: aria-describedby makes the tip a description, not a name, so an icon-only trigger needs aria-label. With interactive: true, exactly one of aria-label or aria-labelledby on Tooltip.Root, and only links inside.

Watch for: Pass your own aria-describedby, onFocus, onBlur, onPointerEnter and onPointerLeave through getTriggerProps(props); put after the spread, they replace the tip's. Your handler runs first. Calling event.preventDefault() in your onPointerEnter or onFocus keeps the tip from opening; a prevented onPointerLeave or onBlur still closes it. Set tooltip={false} on a Button.Root when the hook owns its tip.

When to use

When: A short hint on a trigger that is not a Button.Root, or a tip with links (interactive: true).

When not: An icon-only or truncated Button.Root → its built-in tooltip. Action menus → Menu. Other anchored panels → usePopover. Long help → Description.

Props

useTooltip props
NameTypeDescription
interactiveboolean

Use the non-modal tip dialog. Links only. Never role=tooltip.

Default: false

openboolean

Controlled open state.

defaultOpenboolean

Initial open state when uncontrolled.

onOpenChange(open: boolean, reason: TooltipOpenReason) => void

Fires after a commit. Leaving open unchanged is a veto.

showDelaynumber

Hover show delay in milliseconds. Without it, the tooltip.delay.show token as the trigger computes it. Focus from keys shows at once.

Default: tooltip.delay.show (300ms)

hideDelaynumber

Hide delay in milliseconds. Without it, the tooltip.delay.hide token as the trigger computes it.

Default: tooltip.delay.hide (100ms)

skipDelaynumber

Milliseconds this tip skips its show delay after a hover tip closes. While a hover tip is open, this tip skips that delay too. 0 or less turns skipping off, so this tip always waits. Focus does not start it.

Default: 300

enabledboolean

False resets intent and commits close.

Default: true

idstring

Tooltip id. Default is a generated id.