Back to Ant Design

Tour

components/tour/index.zh-CN.md

6.3.74.9 KB
Original Source

何时使用 {#when-to-use}

常用于引导用户了解产品功能。

代码演示 {#examples}

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">基本</code> <code src="./demo/non-modal.tsx">非模态</code> <code src="./demo/placement.tsx">位置</code> <code src="./demo/mask.tsx">自定义遮罩样式</code> <code src="./demo/indicator.tsx">自定义指示器</code> <code src="./demo/actions-render.tsx" version="5.25.0">自定义操作按钮</code> <code src="./demo/gap.tsx">自定义高亮区域的样式</code> <code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code> <code src="./demo/render-panel.tsx" debug>_InternalPanelDoNotUseOrYouWillBeFired</code>

API

通用属性参考:通用属性

Tour

属性说明类型默认值版本
arrow是否显示箭头,包含是否指向元素中心的配置boolean | { pointAtCenter: boolean}true
classNames用于自定义组件内部各语义化结构的 class,支持对象或函数Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
closeIcon自定义关闭按钮React.ReactNodetrue5.9.0
disabledInteraction禁用高亮区域交互booleanfalse5.13.0
gap控制高亮区域的圆角边框和显示间距{ offset?: number | [number, number]; radius?: number }{ offset?: 6 ; radius?: 2 }5.0.0 (数组类型的 offset: 5.9.0 )
keyboard是否启用键盘快捷行为booleantrue6.2.0
placement引导卡片相对于目标元素的位置center left leftTop leftBottom right rightTop rightBottom top topLeft topRight bottom bottomLeft bottomRightbottom
onClose关闭引导时的回调函数Function-
onFinish引导完成时的回调Function-
mask是否启用蒙层,也可传入配置改变蒙层样式和填充色boolean | { style?: React.CSSProperties; color?: string; }true
type类型,影响底色与文字颜色default | primarydefault
open打开引导boolean-
onChange步骤改变时的回调,current 为当前的步骤(current: number) => void-
current当前处于哪一步number-
scrollIntoViewOptions是否支持当前元素滚动到视窗内,也可传入配置指定滚动视窗的相关参数boolean | ScrollIntoViewOptionstrue5.2.0
styles用于自定义组件内部各语义化结构的行内 style,支持对象或函数Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
indicatorsRender自定义指示器(current: number, total: number) => ReactNode-5.2.0
actionsRender自定义操作按钮(originNode: ReactNode, info: { current: number, total: number }) => ReactNode-5.25.0
zIndexTour 的层级number10015.3.0
getPopupContainer设置 Tour 浮层的渲染节点,默认是 body(node: HTMLElement) => HTMLElementbody5.12.0

TourStep 引导步骤卡片

属性说明类型默认值版本
target获取引导卡片指向的元素,为空时居中于屏幕() => HTMLElement | HTMLElement-
arrow是否显示箭头,包含是否指向元素中心的配置boolean | { pointAtCenter: boolean}true
closeIcon自定义关闭按钮React.ReactNodetrue5.9.0
cover展示的图片或者视频ReactNode-
title标题ReactNode-
description主要描述部分ReactNode-
placement引导卡片相对于目标元素的位置center left leftTop leftBottom right rightTop rightBottom top topLeft topRight bottom bottomLeft bottomRightbottom
onClose关闭引导时的回调函数Function-
mask是否启用蒙层,也可传入配置改变蒙层样式和填充色,默认跟随 Tour 的 mask 属性boolean | { style?: React.CSSProperties; color?: string; }true
type类型,影响底色与文字颜色default | primarydefault
nextButtonProps下一步按钮的属性{ children: ReactNode; onClick: Function }-
prevButtonProps上一步按钮的属性{ children: ReactNode; onClick: Function }-
scrollIntoViewOptions是否支持当前元素滚动到视窗内,也可传入配置指定滚动视窗的相关参数,默认跟随 Tour 的 scrollIntoViewOptions 属性boolean | ScrollIntoViewOptionstrue5.2.0

Semantic DOM

<code src="./demo/_semantic.tsx" simplify="true"></code>

主题变量(Design Token){#design-token}

<ComponentTokenTable component="Tour"></ComponentTokenTable>