useTooltipTrigger

Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button that shows a description when focused or hovered.

Example
Tooltip.tsx
Tooltip.css
Button.css
import {Button} from 'react-aria-components/Button';
import {TooltipTrigger} from './Tooltip';

<div style={{display: 'flex', gap: 8}}>
  <TooltipTrigger tooltip="Edit">
    <Button className="react-aria-Button button-base" data-variant="secondary">Edit</Button>
  </TooltipTrigger>
  <TooltipTrigger tooltip="Delete">
    <Button className="react-aria-Button button-base" data-variant="secondary">Delete</Button>
  </TooltipTrigger>
</div>

API

Shows a tooltip trigger component with labels pointing to its parts, including the tooltip, and trigger elements.FlipTooltipTooltipTrigger
<TooltipTrigger>
  <Button />
  <Tooltip>
    <OverlayArrow />
  </Tooltip>
</TooltipTrigger>
useTooltipTriggerState(props: ): useTooltipTrigger( props: , state: , ref: <FocusableElementnull> ): useTooltip(props: , state?: ):

TooltipTriggerState

Properties

NameType
shouldSkipAnimationboolean

Whether the tooltip is being shown or hidden without an animation. This is true while the global warmup timer is active, i.e. when quickly moving between tooltips.

Methods

open(immediate?: boolean): void
Shows the tooltip. By default, the tooltip becomes visible after a delay depending on a global warmup timer. The immediate option shows the tooltip immediately instead.
close(immediate?: boolean): void
Hides the tooltip.

TooltipTriggerProps

NameTypeDefault
isDisabledbooleanDefault:

Whether the tooltip should be disabled, independent from the trigger.

delaynumberDefault: 1500

The delay time for the tooltip to show up. See guidelines.

closeDelaynumberDefault: 500

The delay time for the tooltip to close. See guidelines.

trigger'hover''focus'Default: 'hover'

By default, opens for both focus and hover. Can be made to open only for focus.

shouldCloseOnPressbooleanDefault: true

Whether the tooltip should close when the trigger is pressed.

TooltipTriggerAria

NameType
tooltipPropsDOMAttributes
Props for the overlay container element.
triggerPropsDOMAttributes
Props for the trigger element.

AriaTooltipProps

NameType

TooltipAria

NameType
tooltipPropsDOMAttributes
Props for the tooltip element.