JGuang

Tour

Tour · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

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

PropertyDescriptionTypeDefaultVersionGlobal Config
arrowWhether to show the arrow, including the configuration whether to point to the center of the elementboolean | { pointAtCenter: boolean }true×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.0
closeIconCustomize close iconReact.ReactNodetrue5.9.05.14.0
disabledInteractionDisable interaction on highlighted area.booleanfalse5.13.0×
gapControl 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)×
keyboardWhether to enable keyboard shortcutsbooleantrue6.2.0×
placementPosition of the guide card relative to the target elementcenter | left | leftTop | leftBottom | right | rightTop | rightBottom | top | topLeft | topRight | bottom | bottomLeft | bottomRightbottom×
onCloseCallback function on shutdownFunction-×
onFinishCallback when the tour is finishedFunction-×
maskWhether to enable masking, change mask style and fill color by pass custom propsboolean | { style?: React.CSSProperties; color?: string; }true×
typeType, affects the background color and text colordefault | primarydefault×
openOpen tourboolean-×
onChangeCallback when the step changes. Current is the previous step(current: number) => void-×
currentWhat is the current stepnumber-×
scrollIntoViewOptionssupport pass custom scrollIntoView optionsboolean | ScrollIntoViewOptionstrue5.2.0×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-6.0.0
indicatorsRendercustom indicator(current: number, total: number) => ReactNode-5.2.0×
actionsRendercustom action(originNode: ReactNode, info: { current: number, total: number }) => ReactNode-5.25.0×
zIndexTour's zIndexnumber10015.3.0×
getPopupContainerSet the rendering node of Tour floating layer(node: HTMLElement) => HTMLElementbody5.12.0×

TourStep

PropertyDescriptionTypeDefaultVersion
targetGet the element the guide card points to. Empty makes it show in center of screen() => HTMLElement | HTMLElement-
arrowWhether to show the arrow, including the configuration whether to point to the center of the elementboolean | { pointAtCenter: boolean}true
closeIconCustomize close iconReact.ReactNodetrue5.9.0
coverDisplayed pictures or videosReactNode-
titletitleReactNode-
descriptiondescriptionReactNode-
placementPosition of the guide card relative to the target elementcenter | left | leftTop | leftBottom | right | rightTop | rightBottom | top | topLeft | topRight | bottom | bottomLeft | bottomRightbottom
onCloseCallback function on shutdownFunction-
maskWhether to enable masking, change mask style and fill color by pass custom props, the default follows the mask property of Tourboolean | { style?: React.CSSProperties; color?: string; }true
typeType, affects the background color and text colordefault | primarydefault
nextButtonPropsProperties of the Next button{ children: ReactNode; onClick: Function }-
prevButtonPropsProperties of the previous button{ children: ReactNode; onClick: Function }-
scrollIntoViewOptionssupport pass custom scrollIntoView options, the default follows the scrollIntoViewOptions property of Tourboolean | ScrollIntoViewOptionstrue5.2.0

Semantic DOM

Semantic nodeNative descriptionVersion
rootTour root container with absolute positioning, z-index control, max width, visibility, arrow background color variable, theme styles and other container styles6.0.0
maskMask layer element with fixed positioning, full screen coverage, z-index, pointer events, transition animation and other mask styles6.0.0
sectionCard main content area with text alignment, border radius, box shadow, relative positioning, background color, border, background clip and other card styles6.0.0
coverCard cover area with text center alignment, padding, image width and other image display styles6.0.0
closeClose button element with absolute positioning, size, color, hover state and other interactive feedback styles6.4.0
headerCard header area with padding, width calculation, word break and other header container styles6.0.0
titleGuide title text with font weight and other title text styles6.0.0
descriptionGuide description text with padding, word wrap and other description text styles6.0.0
footerCard bottom action area with padding, text right alignment, border radius, flex layout and other bottom container styles6.0.0
actionsAction button group container with left auto margin, button spacing and other button group layout styles6.0.0
indicatorsIndicator group container with inline-block display and other indicator container styles6.0.0
indicatorSingle indicator element with width/height size, inline-block display, border radius, background color, right margin, active state and other dot styles6.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.

TokenTypeNative description
zIndexPopupnumberTour popup z-index
closeBtnSizenumberClose button size
primaryPrevBtnBgstringBackground color of previous button in primary type
primaryNextBtnHoverBgstringHover 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.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

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.tsx
  • vendor/components/tour/interface.ts
  • vendor/components/tour/panelRender.tsx
  • vendor/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.