Ant Design Svelte

Tour

Step-by-step introduction: goals, positions, mask, backlight and your own actions.

When to use

Tour sequentially explains interface elements, highlighting related controls. It is suitable for introducing a new work scenario. The tour should be launched with a clear action and have the ability to close; Leave mandatory information available outside of the tour.

Tour CSS prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. The Tour local prefix does not change the Button and Tooltip. The step and open panel are saved when the name is updated.

Steps, goals and status

Steps contains title, description and target. The target is specified by a DOM element or getter; null, undefined, or no target places the card in the center of the screen. Get the component's nativeElement or bind:this of a normal element and pass a getter that is only called in the browser.

Problem Setting Example
Show goal sequence steps, target Main tour
Allow actions on page mask={false} No dimming
Select card side placement Accommodation
Change backlight hole gap, disabledInteraction Geometry
Add your actions actionsRender, cover Action bar
Customize Theme theme.components.Tour Tour theme

open and current - controlled props, without bind. Update them in onClose/onChange; callbacks themselves do not change the value passed by the owner. onChange reports the new index. Without controlled props defaultOpen/defaultCurrent are used; with non-empty steps, the absence of open/defaultOpen may mean an open tour, so set the state explicitly in the application.

Illumination and interaction

gap.offset sets the overall offset or X/Y pair, radius — the rounding of the hole. mask accepts a boolean or a color and a CSS string. disabledInteraction blocks interaction with the selected target rather than the entire page.

The card remains div; Tour does not create a native modal dialog, focus trap, or inert the entire document. The mask controls the pointer. When designing an encounter, separately test the keyboard path, the closing method, and returning the user to the original action.

keyboard controls hot keys; closable:false hides closure and disables Escape. Do not use such a combination without an obvious exit available. onFinish is called when the regular last button ends after onClose.

Placement, actions and topic

placement specifies the preferred side, including center. Flip/shift at the borders of the viewport may change the result; onPopupAlign reports the actual alignment. The arrow/mask/placement/type settings of an individual step take precedence over the general ones.

scrollIntoViewOptions is more reliable to set directly to the step: the default of the step may not be replaced by the root setting. indicatorsRender gets the index and number of steps. actionsRender receives standard action snippet and context; keep the original if you only supplement it with a skip button.

ConfigProvider.tour supplies shared classes and styles. The card and mask use Tour design tokens. Nested buttons use Button settings.

Examples

Dating has not started yet

Normal acquaintance

Three goals, transitions, closure, completion and restart.

Actions: 0

Without mask

Primary card and available target action.

Provisions

Twelve sides and a center; automatic change at borders.

Own mask

Color and CSS masks.

Your own step indicator

Typed Snippet with index and total number.

The tour has not started.

Your actions and cover

Standard buttons are supplemented with a pass.

Backlight radius
Indent X
Y offset
Presses: 0

Backlight geometry

Radius, X/Y padding and interaction blocking.

Semantic DOM

Object, callback and ConfigProvider.tour.

Component Theme Tour

Cross and primary buttons, theme update without resetting the step and separate zIndex priority.

General: suite; local: project-tour

Local Tour prefix does not change Button and Tooltip. The step and open panel are saved when the name is updated.

CSS prefixes Tour

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

API

Eight ant.design 6.7.0 themes verified against the public Svelte API. React render callbacks are adapted as typed Snippets.

Example themes
ThemeExample or limitation
BasicThree guided steps with DOM targets.
Non-modalmask=false and type=primary.
PlacementAll positions and center without target.
Custom mask styleColor and CSS string mask.style.
Custom indicatorSnippet<[current, total]>.
Custom actionSnippet receives standard actions and step information.
Custom highlighted area styleRadius, X/Y offset and disabledInteraction.
Custom semantic dom stylingObject and callback with props.

Tour

PropertyDescriptionTypeDefault
prefixClsFull CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately.stringConfigProvider.prefixCls + "-tour"
stepsSequence of steps.readonly TourStepProps[][]
openControlled visibility. The gallery is explicitly set to false before launch.booleantrue for non-empty steps
defaultOpenInitial visibility of an unguided tour.boolean—
currentManaged index, starting from zero.numberinternal index
defaultCurrentStart internal index; restarting it resets it.number0
onChangeNew step index.(current: number) => void—
onCloseClosing; the owner of the managed open must set it to false.(current: number) => void—
onFinishAfter onClose at the end of the last regular button.() => void—
maskMask and its design.boolean | {color?, style?: string}true
typeCard design.default | primarydefault
placementPreferred side; actual may change with flip.TourPlacementbottom / center without target
arrowArrow at the target. Without a target it is not displayed.boolean | {pointAtCenter: boolean}true
gapGeometry of the highlighted area.{offset?: number | [x, y], radius?: number}offset=6, radius=2
disabledInteractionLocks the pointer in the selected area.booleanfalse
keyboardEscape and ArrowLeft/ArrowRight outside editable fields.booleantrue
closableCross; false also disables Escape.TourClosabletrue
indicatorsRenderYour own indicator with several steps.Snippet<[current: number, total: number]>points
actionsRenderAdd or replace actions.Snippet<[original: Snippet, info: {current, total}]>standard buttons
getPopupContainerGetter must respect calling without a mask argument.false | (target?: HTMLElement) => HTMLElementbody
zIndexExplicit tour layer.number1001 / parent + 100
classNamesSemantic slots classes.TourSlots | callback—
stylesCSS lines semantic slots.TourSlots | callback—

TourStep

PropertyDescriptionTypeDefault
titleText, Snippet or array of content.TourContentis required
descriptionStep description.TourContent—
targetGetter is called in the browser.HTMLElement | null | getterscreen center
coverImage or custom content on top.TourContent—
placementLocal position.TourPlacementgeneral placement
maskLocal mask.TourMaskgeneral mask
typeLocal design.default | primarygeneral type
nextButtonPropschildren, onClick, class and style of the standard button.TourButtonPropslocalization
prevButtonPropsSettings of the previous button.TourButtonPropslocalization
scrollIntoViewOptionsfalse disables autoscrolling for this step.boolean | ScrollIntoViewOptionscenter
renderPanelExtended API for complete panel replacement.Snippet<[TourPanelInfo, current: number]>standard panel

onChange receives a new index. open/current are controlled by the owner, defaultOpen/defaultCurrent set the initial internal state. Don't pass bind:open or bind:current.

Semantic DOM

Named slots are specified via classNames/styles. The tour card is a div, the mask is an SVG with a hole. Tour does not create a native modal dialog or automatically inert the entire page.

Tour
SlotPurpose
rootCard root and root layers.
maskMask with SVG hole.
sectionCard.
coverTop content.
closeClose button.
headerHeader area.
titleHeading.
descriptionDescription.
footerLower area.
actionsActions.
indicatorsAll indicators.
indicatorOne step point.

Registration tokens

theme.components.Tour controls the size of the cross, the colors of the primary buttons and the service geometry of the arrow. The theme is applied to the card and mask and updated without resetting the step. The actual layer is set by the zIndex prop: its default value of 1001 overrides the zIndexPopup CSS token.

TokenPurpose
closeBtnSizeCross size.
primaryPrevBtnBgFrame of the previous button and its background when hovered; also the background of the primary indicators.
primaryNextBtnHoverBgHover of the next button primary.
zIndexPopupThe root layer is 1001. A nested tour derives its layer from its parent.
arrowOffsetHorizontalService horizontal shift of the arrow.
arrowOffsetVerticalService vertical offset.
arrowShadowWidthUtility shadow geometry.
arrowPathService arrow form.
arrowPolygonService polygon arrows.
Common tokens of the current topic
TokenMeaning
colorPrimary#2f54eb
colorBgElevated#ffffff
colorTextrgba(0,0,0,0.88)
colorTextLightSolid#fff
borderRadiusLG8
boxShadowTertiary 0 1px 2px 0 rgba(0,0,0,0.05), 0 1px 6px -1px rgba(0,0,0,0.03), 0 2px 4px 0 rgba(0,0,0,0.03)

FAQ

Why can't bind:open/current?

These are controlled props. Pass the value and update it in callbacks; defaults only work without an external value.

How to specify a goal?

Get nativeElement or bind:this and pass getter. A missing target places the card in the center.

Why did the placement change?

Flip/shift is applied at the viewport borders. The actual alignment is available in onPopupAlign.

Where to set autoscroll?

Pass scrollIntoViewOptions in the step, for example false. The root setting does not always replace the default step.

Does a mask make the page modal?

No. There is no automatic dialog, focus trap and inert of the entire page; disabledInteraction blocks the selected target.

Are Tour tokens applicable?

Yes, to the card and mask. Semantic styles and local provider retain priority; Button theme is independent.

Why doesn't zIndexPopup change the layer?

At the page root, Tour uses layer 1001. Inside another overlay it adds 100 to the parent layer. Set zIndex to choose an explicit layer.