Tooltip

A tooltip is a brief, informative message that appears when a user interacts with an element.

SourceTheme Source@chakra-ui/tooltip

Import#

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

Usage#

<Tooltip.Root>
<Tooltip.Trigger>Hover me</Tooltip.Trigger>
<Tooltip.Positioner>
<Tooltip.Content>See the content</Tooltip.Content>
</Tooltip.Positioner>
</Tooltip.Root>

Using custom component#

To use the tooltip with a custom component, ensure that the component accepts a refand uses forwardRef.

Set the asChild prop to true on the Tooltip.Trigger component to ensure that the tooltip is rendered as a child of the trigger component.

<Tooltip.Root>
<Tooltip.Trigger asChild>
<Tag.Root>
<Tag.Label>Hover me</Tag.Label>
</Tag.Root>
</Tooltip.Trigger>
<Tooltip.Positioner>
<Tooltip.Content>See the content</Tooltip.Content>
</Tooltip.Positioner>
</Tooltip.Root>

Rendering the arrow tip#

Use the Tooltip.Arrow component to render an arrow for the tooltip.

<Tooltip.Root>
<Tooltip.Trigger bg='gray.300' color='black' padding='2' rounded='sm'>
<MdSettings />
</Tooltip.Trigger>
<Tooltip.Positioner>
<Tooltip.Content>
<Tooltip.Arrow />
See the content
</Tooltip.Content>
</Tooltip.Positioner>
</Tooltip.Root>

Disabling the tooltip#

To disable showing a tooltip, pass the disabled prop to the Tooltip component.

<Tooltip.Root disabled>
<Tooltip.Trigger>
<MdSettings />
</Tooltip.Trigger>
<Tooltip.Positioner>
<Tooltip.Content>
<Tooltip.Arrow />
See the content
</Tooltip.Content>
</Tooltip.Positioner>
</Tooltip.Root>

Changing the placement#

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

<Tooltip.Root placement='bottom-start'>
<Tooltip.Trigger>Hover me</Tooltip.Trigger>
<Tooltip.Positioner>
<Tooltip.Content>
<Tooltip.Arrow />
See the content
</Tooltip.Content>
</Tooltip.Positioner>
</Tooltip.Root>

Changing the open and close delay#

<Tooltip.Root openDelay={500} closeDelay={100}>
<Tooltip.Trigger>Hover me</Tooltip.Trigger>
<Tooltip.Positioner>
<Tooltip.Content>
<Tooltip.Arrow />
See the content
</Tooltip.Content>
</Tooltip.Positioner>
</Tooltip.Root>
Edit this page on GitHub

Proudly made inNigeria by Segun Adebayo

Deployed by â–² Vercel