A tooltip is a lightweight overlay that contains a short message which provides the user context about an unknown or unfamiliar element in an interface.
Tooltips are displayed automatically when users hover over (on mouseover) or place focus on a graphical element, such as an icon, image, hyperlink, or form input. They automatically hide when the user moves the mouse (on mouseout) or when focus (blur event) is moved to another element on the page.
Use tooltips:
Avoid using tooltips:
Tooltips can be used with different components, as shown below. Hover over each element to reveal the tooltip.
Property | Type | Default | Description |
---|---|---|---|
children | Node | Required | React component to which the tooltip will be attached. |
message | String | Required | Text to display in the tooltip. |
flipContainer | Element or Element[] | Used to create a boundary for the underlying Popper to stay within. | |
placement | String or String[] | ['right', 'top', 'left', 'bottom'] | Placement of the popover relative to the children element. Options are 'auto' , 'auto-start' , 'auto-end' , 'top' , 'top-start' , 'top-end' , 'bottom' , 'bottom-start' , 'bottom-end' , 'left' , 'left-start' , 'left-end' , 'right' , 'right-start' , 'right-end' . If you use an array of strings, the first item in the array is the default placement and the following ones are chosen in order as fallback placements if the preceding ones don’t work. |
Showing a tooltip on hover or when keyboard focus is placed on a focusable element ensures that all users can access it, even if they aren’t using a mouse.
By default, CoreUI components help assistive technology read the tooltip content by building the following into the default component: