Introduction
Tooltips display informative text when users interact with an element. They are typically used to provide helpful hints or additional context without cluttering the interface.Basic Usage
Positioned Tooltips
TheTooltip has 12 placement choices. They don’t have directional arrows; instead, they rely on motion emanating from the source to convey direction.
Arrow Tooltips
You can use thearrow prop to give your tooltip an arrow indicating which element it refers to.
Custom Child Element
The tooltip needs to apply DOM event listeners to its child element. If the child is a custom React element, you need to make sure that it spreads its props to the underlying DOM element.Triggers
You can define the types of events that cause a tooltip to show. The touch action requires a long press due to theenterTouchDelay prop being set to 700ms by default.
Controlled Tooltips
You can use theopen, onOpen and onClose props to control the behavior of the tooltip.
Variable Width
TheTooltip wraps long text by default to make it readable. You can customize this behavior.
Interactive Tooltips
Tooltips are interactive by default (they close when the user hovers over the tooltip before theleaveDelay expires). You can disable this behavior with disableInteractive.
Disabled Elements
By default, disabled elements like<button> do not trigger user interactions, so a Tooltip will not activate on normal events like hover. To accommodate disabled elements, add a simple wrapper element, such as a span.
Transitions
Use a different transition.Follow Cursor
You can enable the tooltip to follow the cursor by settingfollowCursor={true}.
Delay
The tooltip is normally shown immediately when the user’s mouse hovers over the element. You can use theenterDelay and leaveDelay props to change this behavior.
Props
Tooltip Props
| Prop | Type | Default | Description |
|---|---|---|---|
arrow | boolean | false | If true, adds an arrow to the tooltip. |
children | element | - | Required. Tooltip reference element. |
classes | object | - | Override or extend the styles applied to the component. |
describeChild | boolean | false | If true, the title acts as an accessible description. |
disableFocusListener | boolean | false | Do not respond to focus-visible events. |
disableHoverListener | boolean | false | Do not respond to hover events. |
disableInteractive | boolean | false | Makes tooltip not interactive (closes on hover). |
disableTouchListener | boolean | false | Do not respond to long press touch events. |
enterDelay | number | 100 | Milliseconds to wait before showing the tooltip. |
enterNextDelay | number | 0 | Milliseconds to wait before showing tooltip when one was recently opened. |
enterTouchDelay | number | 700 | Milliseconds a user must touch element before showing tooltip. |
followCursor | boolean | false | If true, the tooltip follows the cursor over the wrapped element. |
id | string | - | ID for the tooltip. Falls back to randomly generated id. |
leaveDelay | number | 0 | Milliseconds to wait before hiding the tooltip. |
leaveTouchDelay | number | 1500 | Milliseconds after user stops touching element before hiding tooltip. |
onClose | function | - | Callback fired when component requests to be closed. |
onOpen | function | - | Callback fired when component requests to be open. |
open | boolean | - | If true, the component is shown (controlled mode). |
placement | 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top' | 'bottom' | Tooltip placement. |
sx | SxProps<Theme> | - | The system prop for defining CSS overrides and additional styles. |
title | node | - | Required. Tooltip title. Zero-length titles are never displayed. |
Slots
| Slot | Type | Default | Description |
|---|---|---|---|
popper | ElementType | Popper | The component used for the popper. |
transition | ElementType | Grow | The component used for the transition. |
tooltip | ElementType | 'div' | The component used for the tooltip. |
arrow | ElementType | 'span' | The component used for the arrow. |
CSS Classes
The following CSS classes are available for customization:.MuiTooltip-popper- Styles applied to the Popper component..MuiTooltip-popperInteractive- Styles applied to the Popper ifdisableInteractive={false}..MuiTooltip-popperArrow- Styles applied to the Popper ifarrow={true}..MuiTooltip-popperClose- Styles applied to the Popper when tooltip is closed..MuiTooltip-tooltip- Styles applied to the tooltip (label wrapper) element..MuiTooltip-tooltipArrow- Styles applied to the tooltip element ifarrow={true}..MuiTooltip-arrow- Styles applied to the arrow element..MuiTooltip-touch- Styles applied to the tooltip on touch devices..MuiTooltip-tooltipPlacementLeft- Styles applied ifplacement="left"..MuiTooltip-tooltipPlacementRight- Styles applied ifplacement="right"..MuiTooltip-tooltipPlacementTop- Styles applied ifplacement="top"..MuiTooltip-tooltipPlacementBottom- Styles applied ifplacement="bottom".
Accessibility
ARIA
By default, the tooltip labels its child element witharia-describedby. This means a screen reader will read the tooltip content when the user focuses the child element.
If you want the tooltip to act as a label instead, use describeChild={false} which applies aria-labelledby:
Keyboard
Tooltips can be triggered via keyboard focus. Make sure interactive elements can receive keyboard focus:Touch Devices
On touch devices, tooltips are shown on long press (700ms by default). You can adjust this withenterTouchDelay: