Tour
A popup component for guiding users through a product.
When To Use
Use when you want to guide users through a product.
Examples
- Basic ·
basic - Non-modal ·
non-modal - Placement ·
placement - Custom mask style ·
mask - Custom indicator ·
indicator - Custom action ·
actions-render - Custom highlighted area style ·
gap - Custom semantic dom styling ·
style-class
API
Common props ref:Common props
Tour
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| arrow | Whether to show the arrow, including the configuration whether to point to the center of the element | boolean | { pointAtCenter: boolean } | true | × | |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 6.0.0 | |
| closeIcon | Customize close icon | React.ReactNode | true | 5.9.0 | 5.14.0 |
| disabledInteraction | Disable interaction on highlighted area. | boolean | false | 5.13.0 | × |
| gap | Control the radius of the highlighted area and the offset between highlighted area and the element. | { offset?: number | [number, number]; radius?: number } | { offset?: 6 ; radius?: 2 } | 5.0.0 (array type offset: 5.9.0) | × |
| keyboard | Whether to enable keyboard shortcuts | boolean | true | 6.2.0 | × |
| placement | Position of the guide card relative to the target element | center | left | leftTop | leftBottom | right | rightTop | rightBottom | top | topLeft | topRight | bottom | bottomLeft | bottomRight | bottom | × | |
| onClose | Callback function on shutdown | Function | - | × | |
| onFinish | Callback when the tour is finished | Function | - | × | |
| mask | Whether to enable masking, change mask style and fill color by pass custom props | boolean | { style?: React.CSSProperties; color?: string; } | true | × | |
| type | Type, affects the background color and text color | default | primary | default | × | |
| open | Open tour | boolean | - | × | |
| onChange | Callback when the step changes. Current is the previous step | (current: number) => void | - | × | |
| current | What is the current step | number | - | × | |
| scrollIntoViewOptions | support pass custom scrollIntoView options | boolean | ScrollIntoViewOptions | true | 5.2.0 | × |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 6.0.0 | |
| indicatorsRender | custom indicator | (current: number, total: number) => ReactNode | - | 5.2.0 | × |
| actionsRender | custom action | (originNode: ReactNode, info: { current: number, total: number }) => ReactNode | - | 5.25.0 | × |
| zIndex | Tour's zIndex | number | 1001 | 5.3.0 | × |
| getPopupContainer | Set the rendering node of Tour floating layer | (node: HTMLElement) => HTMLElement | body | 5.12.0 | × |
TourStep
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| target | Get the element the guide card points to. Empty makes it show in center of screen | () => HTMLElement | HTMLElement | - | |
| arrow | Whether to show the arrow, including the configuration whether to point to the center of the element | boolean | { pointAtCenter: boolean} | true | |
| closeIcon | Customize close icon | React.ReactNode | true | 5.9.0 |
| cover | Displayed pictures or videos | ReactNode | - | |
| title | title | ReactNode | - | |
| description | description | ReactNode | - | |
| placement | Position of the guide card relative to the target element | center | left | leftTop | leftBottom | right | rightTop | rightBottom | top | topLeft | topRight | bottom | bottomLeft | bottomRight | bottom | |
| onClose | Callback function on shutdown | Function | - | |
| mask | Whether to enable masking, change mask style and fill color by pass custom props, the default follows the mask property of Tour | boolean | { style?: React.CSSProperties; color?: string; } | true | |
| type | Type, affects the background color and text color | default | primary | default | |
| nextButtonProps | Properties of the Next button | { children: ReactNode; onClick: Function } | - | |
| prevButtonProps | Properties of the previous button | { children: ReactNode; onClick: Function } | - | |
| scrollIntoViewOptions | support pass custom scrollIntoView options, the default follows the scrollIntoViewOptions property of Tour | boolean | ScrollIntoViewOptions | true | 5.2.0 |
Semantic DOM
| Semantic node | Native description | Version |
|---|---|---|
root | Tour root container with absolute positioning, z-index control, max width, visibility, arrow background color variable, theme styles and other container styles | 6.0.0 |
mask | Mask layer element with fixed positioning, full screen coverage, z-index, pointer events, transition animation and other mask styles | 6.0.0 |
section | Card main content area with text alignment, border radius, box shadow, relative positioning, background color, border, background clip and other card styles | 6.0.0 |
cover | Card cover area with text center alignment, padding, image width and other image display styles | 6.0.0 |
close | Close button element with absolute positioning, size, color, hover state and other interactive feedback styles | 6.4.0 |
header | Card header area with padding, width calculation, word break and other header container styles | 6.0.0 |
title | Guide title text with font weight and other title text styles | 6.0.0 |
description | Guide description text with padding, word wrap and other description text styles | 6.0.0 |
footer | Card bottom action area with padding, text right alignment, border radius, flex layout and other bottom container styles | 6.0.0 |
actions | Action button group container with left auto margin, button spacing and other button group layout styles | 6.0.0 |
indicators | Indicator group container with inline-block display and other indicator container styles | 6.0.0 |
indicator | Single indicator element with width/height size, inline-block display, border radius, background color, right margin, active state and other dot styles | 6.0.0 |
Semantic description source: vendor/components/tour/demo/_semantic.tsx
Design Token
Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.
| Token | Type | Native description |
|---|---|---|
zIndexPopup | number | Tour popup z-index |
closeBtnSize | number | Close button size |
primaryPrevBtnBg | string | Background color of previous button in primary type |
primaryNextBtnHoverBg | string | Hover background color of next button in primary type |
Declaration source: vendor/components/tour/style/index.ts
import { unit } from '@ant-design/cssinjs';
import { FastColor } from '@ant-design/fast-color';
import { genFocusStyle, resetComponent } from '../../style';
import type { ArrowOffsetToken } from '../../style/placementArrow';
import getArrowStyle, {
getArrowOffsetToken,
MAX_VERTICAL_CONTENT_RADIUS,
} from '../../style/placementArrow';
import type { ArrowToken } from '../../style/roundedArrow';
import { getArrowToken } from '../../style/roundedArrow';
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
import { genStyleHooks, mergeToken } from '../../theme/internal';
import { genCssVar } from '../../theme/util/genStyleUtils';
export interface ComponentToken extends ArrowOffsetToken, ArrowToken {
/**
* @desc 弹层 z-index
* @descEN Tour popup z-index
*/
zIndexPopup: number;
/**
* @desc 关闭按钮尺寸
* @descEN Close button size
*/
closeBtnSize: number;
/**
* @desc Primary 模式上一步按钮背景色
* @descEN Background color of previous button in primary type
*/
primaryPrevBtnBg: string;
/**
* @desc Primary 模式下一步按钮悬浮背景色
* @descEN Hover background color of next button in primary type
*/
primaryNextBtnHoverBg: string;
}
interface TourToken extends FullToken<'Tour'> {
indicatorWidth: number | string;
indicatorHeight: number | string;
tourBorderRadius: number;
}
Shared native props
Tips: The following generic properties apply to most antd components; those not supported are described separately.
| Property | Description | Type | Default |
|---|---|---|---|
| style | The additional style | CSSProperties | - |
| className | The additional css class | string | - |
| rootClassName | ClassName on the root element | string | - |
| autoFocus | Auto focus when component mounted, only effective for focusable elements like forms, links, etc. | boolean | false |
Install and reproduce an example
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.
Native type references
The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.
vendor/components/tour/PurePanel.tsxvendor/components/tour/interface.tsvendor/components/tour/panelRender.tsxvendor/components/tour/style/index.ts
Source and license
https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd
Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.