Web · Components
Tooltip
Tooltip briefly explaining what an element does.
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
The tooltip prop on every component
Monthly quota: 80 / 100
interactive: a tooltip with a link inside
VAT included
Tooltip: for your own elements
Import
Tooltip briefly explaining what an element does. Only for extra information; don't hide important information in a tooltip, because not everyone may see it.
Most of the time you don't need to write this component directly: Button, IconButton, Badge, Avatar, Checkbox, Switch, Label, fields, Menu items and Tabs tabs take a tooltip prop (see TooltipProp). Use Tooltip for your own elements.
- Opens on mouse hover (after a short delay) and keyboard focus; closes with Esc.
- Mobile: Since touch screens have no hover, it opens on long press and closes shortly after the finger lifts. A normal tap doesn't break the element's own function. With
touch="tap"it opens on tap. - Disabled elements: Since
disabledbuttons don't get mouse events, they are wrapped in a thin<span>; the tooltip still shows (e.g. "You don't have permission"). - Performance: The tooltip box isn't added to the DOM until first needed (hover, focus, long press); even with hundreds of tooltips on a page the cost is just a few event handlers.
- Accessibility: The text is linked to the element as a description with
aria-describedby; if it equals the element's name (e.g.IconButton) it isn't read twice. - Opens in the browser's top layer (
popover) and is positioned with CSS anchor positioning; if it doesn't fit it flips to the other side. In unsupporting browsers the position is computed once with JavaScript.
Examples
Small ⓘ icon explaining the element next to it; the tooltip opens from this icon. Makes the tooltip reachable for everyone on elements that can't be focused themselves (labels, headings, table columns). The tooltip prop of Label and fields (TextField…) adds it automatically.
- Opens on mouse hover and keyboard focus.
- Mobile: Opens on tap and closes when tapping elsewhere; no need to know about long-pressing. The touch area is enlarged to 44×44 px.
Examples
InfoTipProps
interfaceProps of the InfoTip component.
| Name | Type | Default | Description |
|---|---|---|---|
label? | string | Screen reader name of the icon. If omitted, UIProvider messages.info (default "Bilgi") is used. | |
iconClassName? | string | Classes added to the icon button. For the tooltip box use className. | |
content | ReactNode | Text of the tooltip. Keep it short; a single line is ideal. If empty, no tooltip is shown and only children is rendered. The tooltip box is a <span>; since the trigger can be inside a paragraph (<p>) too, the content must consist of inline elements (text, <strong>, <kbd>, icons); don't put block elements like <div>, <p> or lists. | |
side? | TooltipSide | "auto" | Position relative to the trigger (e.g. "bottom-left"). See TooltipSide. |
delay? | number | 400 | Open delay after the mouse hovers (ms). |
longPressDelay? | number | 500 | Long-press duration to open on touch screens (ms). |
touch? | TooltipTouch | "longPress" | How it opens on touch screens. See TooltipTouch. |
interactive? | boolean | false | Whether the tooltip can be entered. Turn it on if the content has a link or a button (e.g. a "Learn more" link). - Mouse: If the pointer moves from the trigger toward the tooltip, it doesn't close (a "safe area" in the gap between trigger and box); if it moves elsewhere it closes right away. It stays open while over the box, text can be selected and links clicked. - Keyboard: After the trigger, Tab moves to the links in the tooltip; it closes when focus leaves the tooltip. Esc closes it and returns focus to the trigger. - Mobile: A tooltip opened by long press or tap doesn't close by itself when the finger lifts; its link can be tapped, and tapping outside closes it. - Accessibility: Since role="tooltip" can't contain focusable elements, the box becomes role="group"; its text is still linked to the trigger as a description with aria-describedby. Block elements still shouldn't be used in the content with this option (see content). For richer, card-like content use HoverCard. |
closeDelay? | number | 300` if `interactive`, otherwise `0 | Close delay after the mouse leaves (ms). For an interactive tooltip this is the time allowed for the pointer to reach the box. |
tone? | Tone | "neutral" | Semantic color of the tooltip box. "neutral" is a plain box in the page's inverse color; "danger" is for error messages (e.g. the error icon of fields), "warning" for warnings, "success" for confirmations. See Tone. |
className? | string | Classes added to the tooltip box. |
TooltipSide
typePosition of the tooltip relative to the trigger. "auto" starts centered on top; if it doesn't fit it moves below, then to the sides. See Placement.
TooltipTouch
typeHow the tooltip opens on touch screens.
"longPress": Opens on long press; a normal tap does the element's own job (buttons, checkboxes)."tap": Opens/closes on tap; closes when tapping elsewhere (only for informational ⓘ icons).
TooltipProps
interfaceProps of the Tooltip component.
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactElement | The single element triggering the tooltip, usually a button. | |
content | ReactNode | Text of the tooltip. Keep it short; a single line is ideal. If empty, no tooltip is shown and only children is rendered. The tooltip box is a <span>; since the trigger can be inside a paragraph (<p>) too, the content must consist of inline elements (text, <strong>, <kbd>, icons); don't put block elements like <div>, <p> or lists. | |
side? | TooltipSide | "auto" | Position relative to the trigger (e.g. "bottom-left"). See TooltipSide. |
delay? | number | 400 | Open delay after the mouse hovers (ms). |
longPressDelay? | number | 500 | Long-press duration to open on touch screens (ms). |
touch? | TooltipTouch | "longPress" | How it opens on touch screens. See TooltipTouch. |
interactive? | boolean | false | Whether the tooltip can be entered. Turn it on if the content has a link or a button (e.g. a "Learn more" link). - Mouse: If the pointer moves from the trigger toward the tooltip, it doesn't close (a "safe area" in the gap between trigger and box); if it moves elsewhere it closes right away. It stays open while over the box, text can be selected and links clicked. - Keyboard: After the trigger, Tab moves to the links in the tooltip; it closes when focus leaves the tooltip. Esc closes it and returns focus to the trigger. - Mobile: A tooltip opened by long press or tap doesn't close by itself when the finger lifts; its link can be tapped, and tapping outside closes it. - Accessibility: Since role="tooltip" can't contain focusable elements, the box becomes role="group"; its text is still linked to the trigger as a description with aria-describedby. Block elements still shouldn't be used in the content with this option (see content). For richer, card-like content use HoverCard. |
closeDelay? | number | 300` if `interactive`, otherwise `0 | Close delay after the mouse leaves (ms). For an interactive tooltip this is the time allowed for the pointer to reach the box. |
tone? | Tone | "neutral" | Semantic color of the tooltip box. "neutral" is a plain box in the page's inverse color; "danger" is for error messages (e.g. the error icon of fields), "warning" for warnings, "success" for confirmations. See Tone. |
className? | string | Classes added to the tooltip box. |
TooltipOptions
typeSettings given as an object to the tooltip prop.
| Name | Type | Default | Description |
|---|---|---|---|
content | ReactNode | Text of the tooltip. Keep it short; a single line is ideal. If empty, no tooltip is shown and only children is rendered. The tooltip box is a <span>; since the trigger can be inside a paragraph (<p>) too, the content must consist of inline elements (text, <strong>, <kbd>, icons); don't put block elements like <div>, <p> or lists. | |
side? | TooltipSide | "auto" | Position relative to the trigger (e.g. "bottom-left"). See TooltipSide. |
delay? | number | 400 | Open delay after the mouse hovers (ms). |
longPressDelay? | number | 500 | Long-press duration to open on touch screens (ms). |
touch? | TooltipTouch | "longPress" | How it opens on touch screens. See TooltipTouch. |
interactive? | boolean | false | Whether the tooltip can be entered. Turn it on if the content has a link or a button (e.g. a "Learn more" link). - Mouse: If the pointer moves from the trigger toward the tooltip, it doesn't close (a "safe area" in the gap between trigger and box); if it moves elsewhere it closes right away. It stays open while over the box, text can be selected and links clicked. - Keyboard: After the trigger, Tab moves to the links in the tooltip; it closes when focus leaves the tooltip. Esc closes it and returns focus to the trigger. - Mobile: A tooltip opened by long press or tap doesn't close by itself when the finger lifts; its link can be tapped, and tapping outside closes it. - Accessibility: Since role="tooltip" can't contain focusable elements, the box becomes role="group"; its text is still linked to the trigger as a description with aria-describedby. Block elements still shouldn't be used in the content with this option (see content). For richer, card-like content use HoverCard. |
closeDelay? | number | 300` if `interactive`, otherwise `0 | Close delay after the mouse leaves (ms). For an interactive tooltip this is the time allowed for the pointer to reach the box. |
tone? | Tone | "neutral" | Semantic color of the tooltip box. "neutral" is a plain box in the page's inverse color; "danger" is for error messages (e.g. the error icon of fields), "warning" for warnings, "success" for confirmations. See Tone. |
className? | string | Classes added to the tooltip box. |
TooltipProp
typeType of components' tooltip prop. Given in two forms:
- Content:
tooltip="Copy link"or any React content (tooltip={<>Save <kbd>⌘S</kbd></>}). - With settings:
tooltip={{ content: "Save", side: "bottom", delay: 0 }}. SeeTooltipOptions.
false, null or empty text turns the tooltip off (e.g. if you don't want IconButton to show its name as a tooltip).