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
Normal acquaintance
Three goals, transitions, closure, completion and restart.
<script lang="ts">
import { Button, Tour, type TourStepProps } from '@woodger/antd';
let open = $state(false);
let current = $state(0);
let first = $state<HTMLButtonElement | HTMLAnchorElement>();
let second = $state<HTMLButtonElement | HTMLAnchorElement>();
let third = $state<HTMLButtonElement | HTMLAnchorElement>();
let result = $state(("Dating has not started yet"));
const steps: TourStepProps[] = [
{
title: "Upload file",
description: "Here you can select a document for the project.",
target: () => first,
nextButtonProps: { children: "Next" }
},
{
title: "Save changes",
description: "After checking, save the result.",
target: () => second,
nextButtonProps: { children: "Next" },
prevButtonProps: { children: "Back" }
},
{
title: "Other actions",
description: "Additional options are available in this menu.",
target: () => third,
nextButtonProps: { children: "Ready" },
prevButtonProps: { children: "Back" }
}
];
</script>
<style>
.actions {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-top: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<Button type="primary" onclick={() => {
current = 0;
open = true;
result = ("Dating started");
}}>{("Start dating")}</Button>
<div class="actions">
<Button bind:nativeElement={first} onclick={() => {
result = ("File upload selected");
}}>{("Upload file")}</Button>
<Button bind:nativeElement={second} onclick={() => {
result = ("Changes saved");
}}>{("Save changes")}</Button>
<Button bind:nativeElement={third} onclick={() => {
result = ("Other actions selected");
}}>{("Other actions")}</Button>
</div>
<Tour
steps={(steps)}
{open}
{current}
onChange={next => { current = next; }}
onClose={() => {
open = false;
result = ("Acquaintance is closed");
}}
onFinish={() => {
open = false;
result = ("Acquaintance completed");
}}
/>
<output aria-label={("Result of dating")}>{result}</output>
Without mask
Primary card and available target action.
<script lang="ts">
import { Button, Tour } from '@woodger/antd';
let open = $state(false);
let target = $state<HTMLButtonElement | HTMLAnchorElement>();
let count = $state(0);
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div class="actions">
<Button onclick={() => { open = true; }}>
{("Open tour without mask")}
</Button>
<Button bind:nativeElement={target} onclick={() => { count++; }}>
{("Action in a non-modal tour")}
</Button>
</div>
<Tour {open} mask={false} type="primary" steps={([{
title: "Available action",
description: "You can press the highlighted button without closing the tooltip.",
target: () => target
}])}
onClose={() => { open = false; }} />
<output
aria-label={("Actions without a mask")}
>{("Actions: ")}{count}</output>
Provisions
Twelve sides and a center; automatic change at borders.
<script lang="ts">
import { Button, RadioGroup, Tour, type TourPlacement } from '@woodger/antd';
let open = $state(false);
let target = $state<HTMLButtonElement | HTMLAnchorElement>();
let placement = $state<TourPlacement>('bottom');
const placements: TourPlacement[] = [
'center',
'top',
'bottom',
'left',
'right',
'topLeft',
'topRight',
'bottomLeft',
'bottomRight',
'leftTop',
'leftBottom',
'rightTop',
'rightBottom'
];
</script>
<style>
.settings {
display: grid;
gap: 20px;
}
</style>
<div
class="settings"
>
<RadioGroup
aria-label={("Tour position")}
bind:value={placement}
options={(placements)}
/>
<Button bind:nativeElement={target} onclick={() => { open = true; }}>
{("Show selected Tour position")}
</Button>
</div>
<Tour {open} {placement} steps={([{
title: "Selected position",
description: "At the screen border the library can change the side.",
target: placement === 'center' ? null : () => target
}])}
onClose={() => { open = false; }} />
Own mask
Color and CSS masks.
<script lang="ts">
import { Button, Tour } from '@woodger/antd';
let open = $state(false);
let target = $state<HTMLButtonElement | HTMLAnchorElement>();
</script>
<Button bind:nativeElement={target} onclick={() => { open = true; }}>
{("Open a tour with your own mask")}
</Button>
<Tour {open} mask={{ color: 'rgba(35, 20, 0, 0.65)', style: 'backdrop-filter: blur(1px)' }}
steps={([{
title: "Mask of a different color",
description: "Color and CSS belong to the mask setting.",
target: () => target
}])}
onClose={() => { open = false; }} />
Your own step indicator
Typed Snippet with index and total number.
<script lang="ts">
import { Button, Tour } from '@woodger/antd';
let open = $state(false);
let current = $state(0);
</script>
{#snippet indicators(current: number, total: number)}<span>{("Step ")}{(current + 1)}{(" from ")}{(total)}</span>{/snippet}
<Button
onclick={() => { current = 0; open = true; }}
>{("Open tour with counter")}</Button>
<Tour {open} {current} indicatorsRender={indicators} steps={([
{ title: "Plan", description: "Define tasks." },
{ title: "Work", description: "Prepare changes." },
{ title: "Check", description: "Check the result." }
])} onChange={next => { current = next; }} onClose={() => { open = false; }} />
Your actions and cover
Standard buttons are supplemented with a pass.
<script lang="ts">
import type { Snippet } from 'svelte';
import { Button, Tour } from '@woodger/antd';
let open = $state(false);
let result = $state(("The tour has not started."));
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet actions(original: Snippet, info: { current: number; total: number })}
<div class="actions"><Button size="small" onclick={() => {
open = false; result = ("Skipped in step " + String((info.current + 1)) + ".");
}}>{("Skip tour")}</Button>
{@render original()}</div>
{/snippet}
{#snippet cover()}<img
src="/favicon.png"
width="64"
height="64"
alt={("")}
/>{/snippet}
<Button onclick={() => { open = true; result = ("The tour has started."); }}>
{("Open a tour with your actions")}
</Button>
<Tour
{open}
actionsRender={actions}
steps={([
{
title: "Introduction to the project",
description: "Standard buttons are supplemented with their own action.",
cover
},
{ title: "Ready to use", description: "Complete the introduction." }
])}
onClose={() => { open = false; }}
onFinish={() => { result = ("The tour is over."); }}
/>
<output aria-label={("Action Tour")}>{result}</output>
Backlight geometry
Radius, X/Y padding and interaction blocking.
<script lang="ts">
import { Button, Checkbox, InputNumber, Tour } from '@woodger/antd';
let open = $state(false);
let target = $state<HTMLButtonElement | HTMLAnchorElement>();
let radius = $state(12);
let x = $state(12);
let y = $state(8);
let disabledInteraction = $state(false);
let count = $state(0);
</script>
<style>
.settings {
display: grid;
gap: 16px;
margin-bottom: 24px;
}
.field {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<div class="settings">
<div
class="field"
><span>{("Backlight radius")}</span><InputNumber
aria-label={("Backlight Radius Tour")}
min={0}
max={32}
value={radius}
onValueChange={next => { radius = next ?? 0; }}
/></div>
<div class="field"><span>
{("Indent X")}
</span><InputNumber aria-label={("Indentation X Tour")} min={0} max={40} value={x} onValueChange={next => {
x = next
?? 0;
}} /></div>
<div class="field"><span>
{("Y offset")}
</span><InputNumber aria-label={("Indentation Y Tour")} min={0} max={40} value={y} onValueChange={next => {
y = next
?? 0;
}} /></div>
<Checkbox bind:checked={disabledInteraction}>{("Block Target Tour")}</Checkbox>
<Button onclick={() => { open = true; }}>{("Open tour with illumination")}</Button>
</div>
<Button bind:nativeElement={target} onclick={() => { count++; }}>
{("Backlight Purpose Tour")}
</Button>
<Tour {open} gap={{ radius, offset: [x, y] }} {disabledInteraction}
steps={([{
title: "Illumination area",
description: "Settings specify the indents and radius of the mask hole.",
target: () => target
}])}
onClose={() => { open = false; }} />
<output aria-label={("Target Press Tour")}>{("Presses: ")}{count}</output>
Semantic DOM
Object, callback and ConfigProvider.tour.
<script lang="ts">
import { Button, ConfigProvider, Tour } from '@woodger/antd';
let objectOpen = $state(false);
let functionOpen = $state(false);
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
</style>
<ConfigProvider tour={{ styles: { title: 'font-weight: 600' } }}>
<div class="actions">
<Button onclick={() => { objectOpen = true; }}>
{("Open Tour styles object")}
</Button>
<Button
onclick={() => { functionOpen = true; }}
>{("Open Tour style function")}</Button>
</div>
<Tour open={objectOpen} steps={([{
title: "Tour object",
description: "General and local slots."
}])}
classNames={{ root: 'tour-object' }} styles={{ section: 'border: 2px dashed #d48806' }}
onClose={() => { objectOpen = false; }} />
<Tour open={functionOpen} type="primary" steps={([{
title: "Tour function",
description: "The function receives props."
}])}
classNames={{ root: 'tour-function' }} styles={({ props }) => ({
title: props.type === 'primary' ? 'font-weight: 700' : ''
})}
onClose={() => { functionOpen = false; }} />
</ConfigProvider>
Component Theme Tour
Cross and primary buttons, theme update without resetting the step and separate zIndex priority.
<script lang="ts">
import { Button, Checkbox, ConfigProvider, Input, Tour } from '@woodger/antd';
let open = $state(false);
let current = $state(0);
let enabled = $state(true);
let explicitLayer = $state(false);
let draft = $state(("Draft Tour"));
const tokens = {
closeBtnSize: 36,
primaryPrevBtnBg: '#874d00',
primaryNextBtnHoverBg: '#fff1b8',
zIndexPopup: 1300
};
</script>
<style>
.settings {
display: grid;
gap: 16px;
}
label {
display: grid;
gap: 8px;
}
</style>
{#snippet content()}
<div class="settings">
<Checkbox bind:checked={enabled}>{("Apply Tour tokens")}</Checkbox>
<Checkbox bind:checked={explicitLayer}>{("Explicit zIndex: 1400")}</Checkbox>
<label>{("Draft\n ")}<Input bind:value={draft} aria-label={("Tour theme draft")} />
</label>
</div>
{/snippet}
<ConfigProvider direction="rtl" theme={{ components: { Tour: enabled ? tokens : {} } }}>
<Button
onclick={() => { current = 0; open = true; }}
>{("Check theme Tour")}</Button>
<Tour {open} {current} type="primary" zIndex={explicitLayer ? 1400 : undefined}
steps={([
{ title: "First step topic", description: content },
{ title: "Second step topic", description: content }
])}
onChange={next => { current = next; }}
onClose={() => { open = false; }} />
</ConfigProvider>
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.
<script lang="ts">
import { Checkbox, ConfigProvider, Tour, Button } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-tour' : '');
let open = $state(false);
let current = $state(0);
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("General prefix Tour suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Tour")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'tour-theme' } }}>
<div class="prefix-stage">
<Button onclick={() => { current = 0; open = true; }}>
{("Open Tour with prefix")}
</Button>
<Tour
prefixCls={localPrefix}
{open}
{current}
onChange={next => current = next}
onClose={() => open = false}
steps={([
{
title: "First step with prefix",
nextButtonProps: { children: "Next" },
description: "Card, mask and arrows follow prefixCls."
},
{
title: "Second step with prefix",
nextButtonProps: { children: "Complete" },
description: "Buttons use a separate common prefix."
}
])}
/>
</div>
</ConfigProvider>
<output aria-label={("CSS prefix Tour")}>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("Local Tour prefix does not change Button and Tooltip. The step and open panel are saved when the name is updated.")}
</p>
</div>
API
Eight ant.design 6.7.0 themes verified against the public Svelte API. React render callbacks are adapted as typed Snippets.
| Theme | Example or limitation |
|---|---|
| Basic | Three guided steps with DOM targets. |
| Non-modal | mask=false and type=primary. |
| Placement | All positions and center without target. |
| Custom mask style | Color and CSS string mask.style. |
| Custom indicator | Snippet<[current, total]>. |
| Custom action | Snippet receives standard actions and step information. |
| Custom highlighted area style | Radius, X/Y offset and disabledInteraction. |
| Custom semantic dom styling | Object and callback with props. |
Tour
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full 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. | string | ConfigProvider.prefixCls + "-tour" |
steps | Sequence of steps. | readonly TourStepProps[] | [] |
open | Controlled visibility. The gallery is explicitly set to false before launch. | boolean | true for non-empty steps |
defaultOpen | Initial visibility of an unguided tour. | boolean | — |
current | Managed index, starting from zero. | number | internal index |
defaultCurrent | Start internal index; restarting it resets it. | number | 0 |
onChange | New step index. | (current: number) => void | — |
onClose | Closing; the owner of the managed open must set it to false. | (current: number) => void | — |
onFinish | After onClose at the end of the last regular button. | () => void | — |
mask | Mask and its design. | boolean | {color?, style?: string} | true |
type | Card design. | default | primary | default |
placement | Preferred side; actual may change with flip. | TourPlacement | bottom / center without target |
arrow | Arrow at the target. Without a target it is not displayed. | boolean | {pointAtCenter: boolean} | true |
gap | Geometry of the highlighted area. | {offset?: number | [x, y], radius?: number} | offset=6, radius=2 |
disabledInteraction | Locks the pointer in the selected area. | boolean | false |
keyboard | Escape and ArrowLeft/ArrowRight outside editable fields. | boolean | true |
closable | Cross; false also disables Escape. | TourClosable | true |
indicatorsRender | Your own indicator with several steps. | Snippet<[current: number, total: number]> | points |
actionsRender | Add or replace actions. | Snippet<[original: Snippet, info: {current, total}]> | standard buttons |
getPopupContainer | Getter must respect calling without a mask argument. | false | (target?: HTMLElement) => HTMLElement | body |
zIndex | Explicit tour layer. | number | 1001 / parent + 100 |
classNames | Semantic slots classes. | TourSlots | callback | — |
styles | CSS lines semantic slots. | TourSlots | callback | — |
TourStep
| Property | Description | Type | Default |
|---|---|---|---|
title | Text, Snippet or array of content. | TourContent | is required |
description | Step description. | TourContent | — |
target | Getter is called in the browser. | HTMLElement | null | getter | screen center |
cover | Image or custom content on top. | TourContent | — |
placement | Local position. | TourPlacement | general placement |
mask | Local mask. | TourMask | general mask |
type | Local design. | default | primary | general type |
nextButtonProps | children, onClick, class and style of the standard button. | TourButtonProps | localization |
prevButtonProps | Settings of the previous button. | TourButtonProps | localization |
scrollIntoViewOptions | false disables autoscrolling for this step. | boolean | ScrollIntoViewOptions | center |
renderPanel | Extended 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.
| Slot | Purpose |
|---|---|
root | Card root and root layers. |
mask | Mask with SVG hole. |
section | Card. |
cover | Top content. |
close | Close button. |
header | Header area. |
title | Heading. |
description | Description. |
footer | Lower area. |
actions | Actions. |
indicators | All indicators. |
indicator | One 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.
| Token | Purpose |
|---|---|
closeBtnSize | Cross size. |
primaryPrevBtnBg | Frame of the previous button and its background when hovered; also the background of the primary indicators. |
primaryNextBtnHoverBg | Hover of the next button primary. |
zIndexPopup | The root layer is 1001. A nested tour derives its layer from its parent. |
arrowOffsetHorizontal | Service horizontal shift of the arrow. |
arrowOffsetVertical | Service vertical offset. |
arrowShadowWidth | Utility shadow geometry. |
arrowPath | Service arrow form. |
arrowPolygon | Service polygon arrows. |
| Token | Meaning |
|---|---|
colorPrimary | #2f54eb |
colorBgElevated | #ffffff |
colorText | rgba(0,0,0,0.88) |
colorTextLightSolid | #fff |
borderRadiusLG | 8 |
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.