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 children
of Tooltip is a string, wrap within a span
with tabIndex
set to 0
to ensure accessibility requirements are met.
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. | |
defaultIsOpen | boolean | If true , the tooltip is shown initially. | |
label | string | ReactNode | The label of the tooltip. | |
aria-label | string | An alternate label for screen readers. | |
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. | |
shouldWrapChildren | boolean | If true , the tooltip will wrap its children with a Box . | |
onOpen | function | A callback called when the tooltip shows. | |
onClose | function | A callback called when the tooltip hides. |