Tooltip

A tooltip displays a description of an element on hover or focus.

Theme 
placement 
 
 
shouldFlip 
Example
Tooltip.tsx
Tooltip.css
import {TooltipTrigger} from 'react-aria-components';
import {Tooltip} from './Tooltip';
import {Button} from './Button';
import {Edit} from 'lucide-react';

function Example(props) {
  return (
    <TooltipTrigger>
      <Button aria-label="Edit">
        <Edit size={18} />
      </Button>
      <Tooltip {...props}>
        Edit
      </Tooltip>
    </TooltipTrigger>
  );
}

Interactions

Tooltips appear after a "warmup" delay when hovering, or instantly on focus. Once a tooltip is displayed, other tooltips display immediately. If the user waits for the "cooldown period" before hovering another element, the warmup timer restarts.

trigger 
 
 
isDisabled 
shouldCloseOnPress 
import {TooltipTrigger} from 'react-aria-components';
import {Tooltip} from './Tooltip';
import {Button} from './Button';
import {Edit} from 'lucide-react';
import {Save} from 'lucide-react';

function Example(props) {
  return (
    <div style={{display: 'flex', gap: 8}}>
      <TooltipTrigger {...props}>
        <Button aria-label="Edit">
          <Edit size={18} />
        </Button>
        <Tooltip>
          Edit
        </Tooltip>
      </TooltipTrigger>
      <TooltipTrigger {...props}>
        <Button aria-label="Save">
          <Save size={18} />
        </Button>
        <Tooltip>
          Save
        </Tooltip>
      </TooltipTrigger>
    </div>
  );
}

Custom trigger

DialogTrigger works with any focusable React Aria component (e.g. Button, Link, etc.). Use the <Focusable> component to wrap a custom trigger element such as a third party component or DOM element.

Custom trigger
import {Focusable, TooltipTrigger} from 'react-aria-components';
import {Tooltip} from './Tooltip';

<TooltipTrigger>
  <Focusable>
    <span role="button">Custom trigger</span>
  </Focusable>
  <Tooltip>Tooltip</Tooltip>
</TooltipTrigger>
const CustomTrigger = React.forwardRef((props, ref) => (
  <button {...props} ref={ref} />
));

DialogTrigger or MenuTrigger with a <Pressable> trigger also works with TooltipTrigger. All <Pressable> elements are already focusable, so there's no need to wrap them in <Focusable>.

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>

TooltipTrigger

TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip relative to the trigger.

NameTypeDefault
childrenReactNodeDefault:
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.

Tooltip

A tooltip displays a description of an element on hover or focus.

NameTypeDefault
triggerRef<Elementnull>Default:
The ref for the element which the tooltip positions itself with respect to. When used within a TooltipTrigger this is set automatically. It is only required when used standalone.
isEnteringbooleanDefault:
Whether the tooltip is currently performing an entry animation.
isExitingbooleanDefault:
Whether the tooltip is currently performing an exit animation.
placementDefault: 'top'
The placement of the tooltip with respect to the trigger.
arrowBoundaryOffsetnumberDefault: 0
The minimum distance the arrow's edge should be from the edge of the overlay element.
children<>Default:
The children of the component. A function may be provided to alter the children based on component state.

Default className: react-aria-Tooltip

Render PropCSS Selector
placementCSS Selector: [data-placement="left | right | top | bottom"]
The placement of the tooltip relative to the trigger.
isEnteringCSS Selector: [data-entering]
Whether the tooltip is currently entering. Use this to apply animations.
isExitingCSS Selector: [data-exiting]
Whether the tooltip is currently exiting. Use this to apply animations.
stateCSS Selector:
State of the tooltip.
CSS Variable
--trigger-anchor-point
The position of the trigger relative to the tooltip. Use with transform-origin when applying scale transitions.

OverlayArrow

An OverlayArrow renders a custom arrow element relative to an overlay element such as a popover or tooltip such that it aligns with a trigger element.

NameType
children<>
The children of the component. A function may be provided to alter the children based on component state.

Default className: react-aria-OverlayArrow

Render PropCSS Selector
placementCSS Selector: [data-placement="left | right | top | bottom"]
The placement of the overlay relative to the trigger.