logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
6.3.3
  • Components Overview
  • Changelog
    v6.3.3
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • 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
      DEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • ConfigProvider
    • Util
When To Use
Examples
Basic
Smooth Transition
Placement
Arrow
Auto Shift
Colorful Tooltip
Disabled
Wrap custom component
Custom semantic dom styling
API
Common API
ConfigProvider - tooltip.unique
Semantic DOM
Design Token
FAQ
Why doesn't HOC work sometimes?
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?
How to support keyboard accessibility?

Tooltip

Simple text popup box.
Importimport { Tooltip } from 'antd';
GitHub
components/tooltipIssueOpen issues
Docs
Edit this pageLLMs.md
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
    X
    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
    WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
    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

    PropertyDescriptionTypeDefaultVersion
    titleThe text shown in the tooltipReactNode | () => ReactNode--
    colorThe background color. After using this attribute, the internal text color will adapt automaticallystring-5.27.0
    classNamesSemantic DOM classRecord<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-
    stylesSemantic DOM styleRecord<SemanticDOM, CSSProperties> | (info: { props }) => Record<SemanticDOM, CSSProperties>-

    Common API

    The following APIs are shared by Tooltip, Popconfirm, Popover.
    PropertyDescriptionTypeDefaultVersion
    alignPlease 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
    classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
    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.rootReact.CSSProperties-
    overlayInnerStyleStyle of the tooltip inner content, please use styles.bodyReact.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
    stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
    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

    ConfigProvider - tooltip.unique

    You can configure global unique display for Tooltip through ConfigProvider. When unique is set to true, only one Tooltip under the ConfigProvider will be displayed at the same time, providing better user experience and smooth transition effects.

    Note: After configuration, properties like getContainer, arrow etc. will be ignored.

    tsx
    import { Button, ConfigProvider, Space, Tooltip } from 'antd';
    export default () => (
    <ConfigProvider
    tooltip={{
    unique: true,
    }}
    >
    <Space>
    <Tooltip title="First tooltip">
    <Button>Button 1</Button>
    </Tooltip>
    <Tooltip title="Second tooltip">
    <Button>Button 2</Button>
    </Tooltip>
    </Space>
    </ConfigProvider>
    );

    Semantic DOM

    Design Token

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

    FAQ

    Why doesn't HOC work sometimes?

    Please ensure that the child elements of Tooltip can accept onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, onFocus, onClick events.

    Please refer to https://github.com/ant-design/ant-design/issues/15909

    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-component/trigger. @rc-component/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.

    How to support keyboard accessibility?

    By default, Tooltip and similar components trigger on hover rather than focus, so they will not respond to keyboard focus events. If you want the component to support keyboard accessibility, you can enable it in the following ways:

    • Enable for a single component: Set the trigger property to include focus, for example trigger="focus" or trigger={['hover', 'focus']}.
    • Enable globally: Use ConfigProvider to set global configuration, so all relevant components across your application support keyboard focus trigger by default.
    jsx
    import { ConfigProvider, Tooltip, Button } from 'antd';
    // Single component
    <Tooltip trigger={['hover', 'focus']} title="Title">
    <Button>Button</Button>
    </Tooltip>
    // Global configuration
    <ConfigProvider
    tooltip={{ trigger: ['hover', 'focus'] }}
    popover={{ trigger: ['hover', 'focus'] }}
    popconfirm={{ trigger: ['hover', 'focus'] }}
    >
    <App />
    </ConfigProvider>
    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
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Basic

    The simplest usage.

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Placement

    There are 12 placement options available.

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Disabled

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

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Custom semantic dom styling

    You can customize the semantic dom style of Tooltip by passing objects/functions through classNames and styles.

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    6.0.0
    Smooth Transition

    Configure Tooltip unique display through ConfigProvider global configuration to achieve smooth transition effects with only one Tooltip displayed at a time.

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Arrow

    Support show, hide or keep arrow in the center.

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Colorful Tooltip

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

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Wrap custom component

    Use with a custom component.

    CodeSandbox Icon
    Hitu Icon
    codepen icon
    External Link Icon
    Expand Icon
    Tooltip will show on mouse enter.
    Presets
    Custom
    This text is inside a component with the necessary events exposed.
    • root
      Root element (including arrows, content elements) with absolute positioning, z-index, block display, max width, visibility, transform origin and arrow background color
    • container
      Content element with min width and height, padding, color, text alignment, background color, border radius, shadow and border styles
    • arrow
      Arrow element with width, height, position, color and border styles