logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.25.4
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
      5.13.0
When To Use
Examples
Basic
Placement
Arrow
Auto Shift
Colorful Tooltip
Disabled
Wrap custom component
API
Common API
Semantic DOM
Design Token
FAQ
Why Tooltip not update content when close?
Why does the warning findDOMNode is deprecated sometimes appear in strict mode?
Why is the tooltip for my custom component not opening?
What's the placement logic?

Tooltip

Simple text popup box.
Importimport { Tooltip } from "antd";
Sourcecomponents/tooltip
Docs
Edit this pageChangelog
contributors
  • TimelineTour

    Resources

    Ant Design X
    Ant Design Charts
    Ant Design Pro
    Pro Components
    Ant Design Mobile
    Ant Design Mini
    Ant Design Web3
    Ant Design Landing-Landing Templates
    Scaffolds-Scaffold Market
    Umi-React Application Framework
    dumi-Component doc generator
    qiankun-Micro-Frontends Framework
    Ant Motion-Motion Solution
    China Mirror 🇨🇳

    Community

    Awesome Ant Design
    Medium
    Twitter
    yuque logoAnt Design in YuQue
    Ant Design in Zhihu
    Experience Cloud Blog
    seeconf logoSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTech logoMore Products

    yuque logoYuQue-Document Collaboration Platform
    AntV logoAntV-Data Visualization
    Egg logoEgg-Enterprise Node.js Framework
    Kitchen logoKitchen-Sketch Toolkit
    Galacean logoGalacean-Interactive Graphics Solution
    xtech logoAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Ant Design Community
    loading

    When To Use

    • The tip is shown on mouse enter, and is hidden on mouse leave. The Tooltip doesn't support complex text or operations.
    • To provide an explanation of a button/text/operation. It's often used instead of the html title attribute.

    Examples

    API

    Common props ref:Common props

    PropertyDescriptionTypeDefault
    titleThe text shown in the tooltipReactNode | () => ReactNode-

    Common API

    The following APIs are shared by Tooltip, Popconfirm, Popover.
    PropertyDescriptionTypeDefaultVersion
    alignThis value will be merged into placement's config, please refer to the settings dom-alignobject-
    arrowChange arrow's visible state and change whether the arrow is pointed at the center of target.boolean | { pointAtCenter: boolean }true5.2.0
    autoAdjustOverflowWhether to adjust popup placement automatically when popup is off screenbooleantrue
    colorThe background colorstring-4.3.0
    defaultOpenWhether the floating tooltip card is open by defaultbooleanfalse4.23.0
    destroyTooltipOnHideWhether destroy dom when closebooleanfalse
    destroyOnHiddenWhether destroy dom when closebooleanfalse5.25.0
    freshTooltip will cache content when it is closed by default. Setting this property will always keep updatingbooleanfalse5.10.0
    getPopupContainerThe DOM container of the tip, the default behavior is to create a div element in body(triggerNode: HTMLElement) => HTMLElement() => document.body
    mouseEnterDelayDelay in seconds, before tooltip is shown on mouse enternumber0.1
    mouseLeaveDelayDelay in seconds, before tooltip is hidden on mouse leavenumber0.1
    overlayClassNameClass name of the tooltip card, please use classNames={{ root: '' }} insteadstring-
    overlayStyleStyle of the tooltip card, please use styles={{ root: {} }}React.CSSProperties-
    overlayInnerStyleStyle of the tooltip inner content, please use styles={{ body: {} }}React.CSSProperties-
    placementThe position of the tooltip relative to the target, which can be one of top left right bottom topLeft topRight bottomLeft bottomRight leftTop leftBottom rightTop rightBottomstringtop
    triggerTooltip trigger mode. Could be multiple by passing an arrayhover | focus | click | contextMenu | Array<string>hover
    openWhether the floating tooltip card is open or not. Use visible under 4.23.0 (why?)booleanfalse4.23.0
    zIndexConfig z-index of Tooltipnumber-
    onOpenChangeCallback executed when visibility of the tooltip card is changed(open: boolean) => void-4.23.0

    Semantic DOM

    Design Token

    Component TokenHow to use?
    Token NameDescriptionTypeDefault Value
    zIndexPopupz-index of tooltipnumber1070
    Global TokenHow to use?

    FAQ

    Why Tooltip not update content when close?

    Tooltip will cache content when it is closed to avoid flicker when content is updated:

    jsx
    // `title` will not blink when `user` is empty
    <Tooltip open={user} title={user?.name} />
    no blink

    If need update content when close, you can set fresh property (#44830):

    jsx
    <Tooltip open={user} title={user?.name} fresh />
    no blink

    The following FAQ applies to Tooltip, Popconfirm, Popover components.

    Why does the warning findDOMNode is deprecated sometimes appear in strict mode?

    This is due to the implementation of rc-trigger. rc-trigger forces children to accept ref, otherwise it will fall back to findDOMNode, so children need to be native html tags. If not, you need to use React.forwardRef transparently passes ref to native html tags.

    • findDOMNode is deprecated reproduce: https://codesandbox.io/p/sandbox/finddomnode-c5hy96
    • Using forwardRef to fix: https://codesandbox.io/p/sandbox/no-finddomnode-warning-forked-gdxczs

    Why is the tooltip for my custom component not opening?

    Similar issues: #15909, #12812.

    Please ensure that the child node to accept onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, onFocus, and onClick events, If you create your own component and do not explicitly add these mouse and pointer events as props, the tooltip will never appear. See Example.

    What's the placement logic?

    It will follow placement config when screen has enough space. And flip when space is not enough (Such as top to bottom or topLeft to bottomLeft). Single direction such as top bottom left right will auto shift on the view:

    shift

    When placement is set to edge align such as topLeft bottomRight, it will only do flip but not do shift.

    Auto Shift

    Auto adjust Popup and arrow position when Tooltip is close to the edge of the screen. Will be out of screen when exceed limitation.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Basic

    The simplest usage.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Arrow

    Support show, hide or keep arrow in the center.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Colorful Tooltip

    We preset a series of colorful Tooltip styles for use in different situations.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Wrap custom component

    Use with a custom component.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Placement

    There are 12 placement options available.

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Disabled

    The Tooltip can be disabled by setting title={null} or title="".

    CodeSandbox Icon
    codeblock
    codepen icon
    External Link Icon
    expand codeexpand code
    Tooltip will show on mouse enter.
    Presets
    Custom
    This text is inside a component with the necessary events exposed.
    • root
      5.23.0
      Root element (including arrows, content elements)
    • body
      5.23.0
      Body element