Skip to main content

Tooltip

Tooltip displays short, non-interactive text when its trigger receives a hover or focus event.

Open in Storybook

Import​

import { Tooltip } from "@tosui/react";

Basic usage​

Placement​

Delays​

openDelay and closeDelay are durations in milliseconds.

Disabled state​

Controlled state​

Pass isOpen when application state owns the open state. Update that state from onOpen and onClose.

function ControlledTooltip() {
const [isOpen, setIsOpen] = useState(false);

return (
<Tooltip
label="Controlled tooltip"
isOpen={isOpen}
onOpen={() => setIsOpen(true)}
onClose={() => setIsOpen(false)}
>
<Button>Controlled</Button>
</Tooltip>
);
}

Common patterns​

IconButton with Tooltip​

<Tooltip label="Settings">
<IconButton aria-label="Settings">
<SettingsIcon />
</IconButton>
</Tooltip>

Truncated text with a tooltip​

<Tooltip label="This is the full text that doesn't fit in the container">
<Text
truncate
maxW="150px"
>
This is the full text that doesn't fit in the container
</Text>
</Tooltip>

Disabled button explanation​

<Tooltip label="You need admin permissions to perform this action">
<Box as="span">
<Button disabled>Delete All</Button>
</Box>
</Tooltip>

Props reference​

PropTypeDefaultDescription
labelReactNode-Tooltip content (required)
placement"top" | "bottom" | "left" | "right""top"Tooltip position
openDelaynumber0Delay before showing (ms)
closeDelaynumber0Delay before hiding (ms)
disabledbooleanfalseWhether tooltip is disabled
isOpenboolean-Controlled open state
onOpen() => void-Callback when tooltip opens
onClose() => void-Callback when tooltip closes
classNamestring-Additional CSS class on the tooltip panel
childrenReactNode-Trigger element (required)

Accessibility​

  • The overlay uses role="tooltip" and has a generated ID.
  • While the tooltip is open, its focusable trigger receives the tooltip ID in aria-describedby.
  • Existing aria-describedby IDs remain on the trigger.
  • If the child has no focusable element, the trigger wrapper receives tabIndex={0} so keyboard users can open the tooltip.
  • A disabled tooltip does not add a tab stop or an accessible description.
  • The portal renders only in the browser, which keeps server rendering deterministic.

TypeScript​

import { Tooltip, type TooltipPlacement, type TooltipProps } from "@tosui/react";