Tooltip
A tooltip is a brief, informative message that appears when a user interacts with an element. Tooltips are usually initiated in one of two ways: through a mouse-hover or keyboard-hover action.
The Tooltip
component follows the WAI-ARIA Tooltip pattern.
Import
Usage
If the tooltip anchor is not a focusable content, just like the text string, you can wrap it with a Text
component and set `tabIndex="0" to make it focusable.
EDITABLE EXAMPLE
With an icon
EDITABLE EXAMPLE
Hide the arrow
EDITABLE EXAMPLE
Tooltip with focusable content
If the children of Tooltip are focusable elements, Tooltip will show when you focus or hover on the a children element and will hide when you blur or move cursor out of the element.
EDITABLE EXAMPLE
Customized tooltips
EDITABLE EXAMPLE
Tooltip with Menu
EDITABLE EXAMPLE
Placement
Using the placement
prop you can adjust where your tooltip will be displayed.
EDITABLE EXAMPLE
Props
Name | Type | Default | Description |
---|---|---|---|
isOpen | boolean | If true , the tooltip is shown. | |
label | string | ReactNode | The label of the tooltip. | |
placement | PopperJS.Placement | 'bottom' | Position the tooltip relative to the trigger element as well as surrounding elements. Possible values: 'top' , 'bottom' , 'right' , 'left' , 'top-start' , 'top-end' , 'bottom-start' , 'bottom-end' , 'right-start' , 'right-end' , 'left-start' , 'left-end' |
children | ReactNode | The ReactNode element to be used as the trigger of the tooltip. | |
hideArrow | boolean | If true , hide the arrow tip on the tooltip. | |
arrowAt | string | The arrow is at the position of the popover. Possible values: 'left' , 'right' , 'top' , 'bottom' | |
showDelay | number | The delay in milliseconds for the tooltip to show. | |
hideDelay | number | The delay in milliseconds for the tooltip to hide. | |
closeOnClick | boolean | If true , hide the tooltip when the trigger is clicked. | |
onOpen | function | A callback called when the tooltip shows. | |
onClose | function | A callback called when the tooltip hides. |