--- title: Tooltip description: "`Tooltip` is a component that displays short information, such as supplementary details for an element." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/tooltip/tooltip.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/tooltip - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-tooltip--basic --- ```tsx ``` ## Usage ```tsx import { Tooltip } from "@yamada-ui/react" ``` ```tsx import { Tooltip } from "@/components/ui" ``` ```tsx import { Tooltip } from "@workspaces/ui" ``` ```tsx ``` ### Change the Display Position To change the display position, set `placement` to values like `"end"` or `"center-start"`. By default, `"start"` is set. ```tsx {(placement, index) => ( )} ``` ### Change the Animation To change the show or hide animation, set `animation` to values like `"top"` or `"left"`. By default, `"scale"` is set. ```tsx {(animationScheme, index) => ( )} ``` ### Change the Duration To change the duration, set `duration` to a number (seconds). ```tsx ``` ### Change the Offset To change the offset, set `gutter` or `offset` to a value. `gutter` allows you to set the difference with simple elements, and `offset` allows you to set `[horizontal axis, vertical axis]`. ```tsx ``` ### Delay If you want to delay the display or hiding, set `openDelay` or `closeDelay` to a number (milliseconds). ```tsx ``` ### Disable To disable the tooltip, set `disabled` to `true`. ```tsx ``` ### Always Display To always display the tooltip, set `open` to `true`. ```tsx ``` ## Props | Prop | Default | Type | Description | | -------------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `animationScheme` | `"scale"` | `"none" \| "scale" \| SimplePlacement` | The animation of the element. | | `autoUpdate` | `true` | `boolean` | If `true`, automatically updates the position of the floating element when necessary. | | `closeDelay` | `100` | `number` | The delay before hiding the tooltip. | | `closeOnClick` | `true` | `boolean` | If `true`, the tooltip will hide on click. | | `closeOnEsc` | `true` | `boolean` | If `true`, the tooltip will hide on pressing Esc key. | | `closeOnScroll` | `false` | `boolean` | If `true`, the tooltip will hide on scroll. | | `content` | - | `ReactNode` | The content of the tooltip. | | `contentProps` | - | `HTMLMotionProps` | Props for content element. | | `defaultOpen` | - | `boolean` | If `true`, the element will be initially opened. | | `disabled` | `false` | `boolean` | If `true`, the tooltip will be disabled. | | `duration` | `0.1` | `PopupAnimationProps["duration"]` | The animation duration. | | `elements` | - | `{ | | floating?: HTMLElement \| null | | reference?: null \| Reference | | }` | Object containing the reference and floating elements. | | `flip` | `true` | `boolean` | If `true`, the popper will change its placement and flip when it's about to overflow its boundary area. | | `gutter` | `8` | `number` | The distance or margin between the reference and popper. It is used internally to create an `offset` modifier. | | `matchWidth` | `false` | `boolean` | If `true`, the popper will match the width of the reference at all times. It's useful for `autocomplete`, `date-picker` and `select` patterns. | | `middleware` | - | `(false \| Middleware \| null \| undefined)[]` | Array of middleware objects to modify the positioning or provide data for rendering. | | `offset` | - | `[number, number]` | The main and cross-axis offset to displace popper element from its reference element. | | `onClose` | - | `() => void \| Promise` | Callback invoked to close the element. | | `onOpen` | - | `() => void \| Promise` | Callback invoked to open the element. | | `open` | - | `boolean` | If `true`, the element will be opened. | | `openDelay` | `400` | `number` | The delay before showing the tooltip. | | `placement` | `"start"` | `Direction` | The placement of the popper relative to its reference. | | `platform` | - | `Platform` | Custom or extended platform object. | | `portalProps` | - | `Omit` | Props for portal component. | | `preventOverflow` | `true` | `boolean` | If `true`, will prevent the popper from being cut off and ensure it's visible within the boundary area. | | `strategy` | `"absolute"` | `Strategy` | The CSS positioning strategy to use. | | `transform` | `true` | `boolean` | Whether to use `transform` for positioning instead of `top` and `left` (layout) in the `floatingStyles` object. | | `whileElementsMounted` | - | `(reference: Reference, floating: HTMLElement, update: () => void) => () => void` | A callback invoked when both the reference and floating elements are mounted, and cleaned up when either is unmounted. This is useful for setting up event listeners (e.g. pass `autoUpdate`). | ## Accessibility Currently, this section is being updated due to the migration of v2.