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 gesture or through a keyboard-hover gesture.

chakra ui pro

The Tooltip component follows the WAI-ARIA Tooltip Pattern.

Import#

import { Tooltip } from "@chakra-ui/react"

Usage#

If the children of Tooltip is a string, we wrap with in a span with tabIndex set to 0, to ensure it meets the accessibility requirements.

Note 🚨: If the Tooltip is wrapping a functional component, ensure that the functional component accepts a ref using forwardRef.

Hover me
Editable Example

With an icon#

Editable Example

Note 🚨: If you're wrapping an icon from react-icons, you need to also wrap the icon in a span element as react-icons icons do not use forwardRef.

With arrow#

Editable Example

Tooltip with focusable content#

If the children of the tooltip is a focusable element, the tooltip will show when you focus or hover on the element, and will hide when you blur or move cursor out of the element.

Editable Example

Disabled Tooltip#

Editable Example

Placement#

Using the placement prop you can adjust where your tooltip will be displayed.

Editable Example

More examples#

Editable Example

Props#

childrenrequired

Description

The react component to use as the trigger for the tooltip

Type
ReactNode

aria-label

Description

The accessible, human friendly label to use for screen readers. If passed, tooltip will show the content label but expose only `aria-label` to assistive technologies

Type
string

arrowPadding

Description

The padding required to prevent the arrow from reaching the very edge of the popper.

Type
number
Default
8

arrowShadowColor

Type
string

arrowSize

Type
number

closeDelay

Description

Delay (in ms) before hiding the tooltip

Type
number
Default
0ms

closeOnClick

Description

If true, the tooltip will hide on click

Type
boolean

closeOnMouseDown

Description

If true, the tooltip will hide while the mouse is down

Type
boolean

colorScheme

Description

Color Schemes for Tooltip are not implemented in the default theme. You can extend the theme to implement them.

Type
"whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"

defaultIsOpen

Description

If true, the tooltip will be initially shown

Type
boolean

gutter

Description

The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.

Type
number
Default
8

hasArrow

Description

If true, the tooltip will show an arrow tip

Type
boolean

isDisabled

Type
boolean

isOpen

Description

If true, the tooltip will be shown (in controlled mode)

Type
boolean

label

Description

The label of the tooltip

Type
ReactNode

modifiers

Description

Array of popper.js modifiers. Check the docs to see the list of possible modifiers you can pass. @see Docs https://popper.js.org/docs/v2/modifiers/

Type
Partial<Modifier<string, any>>[]

offset

Description

The main and cross-axis offset to displace popper element from its reference element.

Type
[crossAxis: number, mainAxis: number]

onClose

Description

Callback to run when the tooltip hides

Type
(() => void)

onOpen

Description

Callback to run when the tooltip shows

Type
(() => void)

openDelay

Description

Delay (in ms) before showing the tooltip

Type
number
Default
0ms

placement

Description

The Popper.js placement of the tooltip

Type
"bottom" | "left" | "right" | "top" | "auto" | "auto-start" | "auto-end" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end"

portalProps

Description

Props to be forwarded to the portal component

Type
Pick<PortalProps, "appendToParentPortal" | "containerRef">

shouldWrapChildren

Description

If true, the tooltip will wrap its children in a `<span/>` with `tabIndex=0`

Type
boolean

size

Description

Sizes for Tooltip are not implemented in the default theme. You can extend the theme to implement them.

Type
string

variant

Description

Variants for Tooltip are not implemented in the default theme. You can extend the theme to implement them.

Type
string
Edit this page

Proudly made inNigeria by Segun Adebayo