生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

Tour ​

Navigation component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="tour": root · backdrop · spotlight · positioner · content · title · description · progress-text · progress-indicator · progress-dot · prev-trigger · next-trigger · skip-trigger · close-trigger · arrow

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-tour>
Vue componentsXhTourArrow XhTourBackdrop XhTourCloseTrigger XhTourContent XhTourDescription XhTourNextTrigger XhTourPositioner XhTourPrevTrigger XhTourProgressDot XhTourProgressIndicator XhTourProgressText XhTourRoot XhTourSkipTrigger XhTourSpotlight XhTourTitle
ComposableuseTour
State machinetourMachine
Skin@xihan-ui/styles/tour.css

Props ​

PropTypeRequired
stepsTourStep[]
valuenumber
defaultValuenumber
openboolean
defaultOpenboolean
placementPlacement
dirDirection
offsetnumber
closeOnEscapeboolean
closeOnInteractOutsideboolean
showBackdropboolean
spotlightPaddingnumber
boundaryTourTarget | null
autoScrollboolean
targetTimeoutnumber
partsTitleDescriptionParts
translationsPartial<TourTranslations>
onValueChange(details: TourValueChangeDetails) => void
onOpenChange(details: TourOpenChangeDetails) => void
onComplete(details: TourCompleteDetails) => void
onSkip(details: TourSkipDetails) => void

TourStep ​

Elements of steps.

FieldTypeRequired
idstringYes
targetTourTarget | null
titlestring
descriptionstring
placementPlacement

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
open-changeTourOpenChangeDetails
value-changeTourValueChangeDetails
completeTourCompleteDetails
skipTourSkipDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhTourRootdefaultTourRootSlotProps

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhTourProgressDotindexnumber | stringYes
XhTourRootcontainer() => Element | null
XhTourRootchildrenSlotChildren<TourRootSlotProps>

State ​

Public state is written to data-state.

PartValues
root'open' | 'closed'
backdrop'open' | 'closed'
spotlight'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'
prev-trigger'open' | 'closed'
next-trigger'open' | 'closed'
skip-trigger'open' | 'closed'

The following names are internal to the state machine.

States: open · closed

Events: OPEN · CLOSE · VALUE.SET · STEP.PREV · STEP.NEXT · SKIP · GEOMETRY.SYNC · TARGET.FOUND · TARGET.MISSING · STEP.SETTLED · CONTROLLED.OPEN · CONTROLLED.CLOSE · PRESS.START · PRESS.END

Guards: isOpenControlled · isLastStep · isLastStepOpenControlled · canPress

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
openboolean
valuenumber
countnumber
currentStepTourStep | null
firstStepboolean
lastStepboolean
anchoredboolean
progressTextstring
setOpen(next: boolean) => void
setValue(next: number) => void
goToNextStep() => void
goToPrevStep() => void
skip() => void
remeasure() => void
getRootProps() => T['element']
getBackdropProps() => T['element']
getSpotlightProps() => T['element']
getPositionerProps() => T['element']
getContentProps() => T['element']
getTitleProps() => T['element']
getDescriptionProps() => T['element']
getProgressTextProps() => T['element']
getProgressIndicatorProps() => T['element']
getProgressDotProps(props: TourProgressDotProps) => T['element']
getPrevTriggerProps() => T['button']
getNextTriggerProps() => T['button']
getSkipTriggerProps() => T['button']
getCloseTriggerProps() => T['button']
getArrowProps() => T['element']

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
Enter / Spacetour.kbd.next
Escapetour.kbd.escape
ArrowUp / ArrowDown / ArrowLeft / ArrowRighttour.kbd.arrows
Tab / Shift+Tabtour.kbd.trap
Enter / Spacetour.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
backdroparia-hidden'true'
spotlightaria-hidden'true'
contentaria-describedbyid of the description part | undefined
contentaria-hidden!open || undefined
contentaria-labelledbyid of the title part | undefined
contentaria-modal'true' | undefined
contentrole'dialog'
progress-textaria-live'polite'
progress-indicatoraria-hidden'true'
next-triggeraria-labeltranslations.finish | translations.next
close-triggeraria-labeltranslations.close
arrowaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/tour.css is written against [data-scope="tour"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-tour in place of data-scope (same specificity) and sits in the xihan.components and xihan.motion layers. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-empty'' (present only while the condition holds)
rootdata-state'open' | 'closed'
rootdata-stepString(value)
backdropdata-instant'' (present only while the condition holds)
backdropdata-position'anchored' | 'center'
backdropdata-state'open' | 'closed'
spotlightdata-animating'' (present only while the condition holds)
spotlightdata-dimmed'' (present only while the condition holds)
spotlightdata-instant'' (present only while the condition holds)
spotlightdata-state'open' | 'closed'
positionerdata-animating'' (present only while the condition holds)
positionerdata-placementactual placement computed by the positioning engine
positionerdata-position'anchored' | 'center'
positionerdata-positioned'' (present only while the condition holds)
positionerdata-state'open' | 'closed'
contentdata-instant'' (present only while the condition holds)
contentdata-placementactual placement computed by the positioning engine
contentdata-state'open' | 'closed'
contentdata-stepString(value)
progress-textdata-stepString(value)
progress-indicatordata-countString(count)
progress-indicatordata-stepString(value)
progress-dotdata-complete'' (present only while the condition holds)
progress-dotdata-current'' (present only while the condition holds)
progress-dotdata-indexString(index)
prev-triggerdata-disabled'' (present only while the condition holds)
prev-triggerdata-pressed'' (present only while the condition holds)
prev-triggerdata-state'open' | 'closed'
prev-triggerdata-xh-action-control''
prev-triggerdata-xh-action-display'always'
prev-triggerdata-xh-action-profile'text'
prev-triggerdata-xh-action-size'sm'
prev-triggerdata-xh-action-variant'outline'
next-triggerdata-last'' (present only while the condition holds)
next-triggerdata-pressed'' (present only while the condition holds)
next-triggerdata-state'open' | 'closed'
next-triggerdata-xh-action-control''
next-triggerdata-xh-action-display'always'
next-triggerdata-xh-action-profile'text'
next-triggerdata-xh-action-size'sm'
next-triggerdata-xh-action-variant'solid'
next-triggerdata-xh-ink-surface''
skip-triggerdata-pressed'' (present only while the condition holds)
skip-triggerdata-state'open' | 'closed'
skip-triggerdata-xh-action-control''
skip-triggerdata-xh-action-display'always'
skip-triggerdata-xh-action-profile'text'
skip-triggerdata-xh-action-size'sm'
skip-triggerdata-xh-action-variant'ghost'
close-triggerdata-pressed'' (present only while the condition holds)
close-triggerdata-xh-action-control''
close-triggerdata-xh-action-display'always'
close-triggerdata-xh-action-profile'icon'
close-triggerdata-xh-action-size'sm'
close-triggerdata-xh-action-variant'ghost'
arrowdata-placementactual placement computed by the positioning engine

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-tour-action-radiusnext-trigger
prev-trigger
skip-trigger
border-radiusdefault--xh-shape-control
--xh-tour-arrow-sizearrow--xh-_overlay-arrow-sizedefault--xh-overlay-arrow-size
--xh-tour-backdrop-bgbackdropbackgrounddefault--xh-bg-overlay
--xh-tour-backdrop-layerbackdropz-indexdefault--xh-_layer
--xh-tour-bgarrow
content
backgrounddefault--xh-material-elevated-bg
--xh-tour-borderarrow
content
borderdefault--xh-material-elevated-border
--xh-tour-close-bg-activeclose-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-tour-close-bg-hoverclose-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-tour-close-fgclose-triggercolordefault--xh-fg-muted
--xh-tour-close-fg-hoverclose-triggercolordisabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-tour-close-radiusclose-triggerborder-radiusdefault--xh-shape-control
--xh-tour-close-sizeclose-trigger
content
title
block-size
inline-size
padding-inline-end
default
has([data-scope='tour'][data-part='close-trigger'])
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-control-h-sm
--xh-tour-description-fgdescriptioncolordefault--xh-fg-muted
--xh-tour-description-font-sizedescriptionfont-sizedefault--xh-text-secondary-size
--xh-tour-fgcontent
root
colordefault--xh-fg-default
--xh-material-elevated-fg
--xh-tour-gapcontent
description
title
gap
margin-block-start
default--xh-space-2
--xh-tour-icon-sizeclose-trigger
content
next-trigger
prev-trigger
root
skip-trigger
--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-glyph-size-md
--xh-tour-max-hcontentmax-block-sizedefault--xh-overlay-max-h
--xh-tour-max-wcontentmax-inline-sizedefault--xh-overlay-max-w-lg
--xh-tour-next-bgnext-trigger--xh-ink-surface
background-color
default
focus-visible
xh-ink-surface
--xh-_action-variant-bg-focus-visible
--xh-_action-variant-bg-rest
--xh-tour-next-bg-hovernext-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-tour-next-fgnext-triggercolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-tour-next-shadownext-triggerbox-shadowdefaultnone
--xh-tour-positioner-layerpositionerz-indexdefault--xh-_layer
--xh-tour-positioner-paddingpositionerpaddingposition=center--xh-space-4
--xh-tour-progress-dot-bgprogress-dotbackgrounddefault--xh-border-default
--xh-tour-progress-dot-bg-completeprogress-dotbackgroundcomplete--xh-border-strong
--xh-tour-progress-dot-bg-currentprogress-dotbackgroundcurrent--xh-bg-brand
--xh-tour-progress-fgprogress-textcolordefault--xh-fg-subtle
--xh-tour-progress-font-sizeprogress-textfont-sizedefault--xh-text-caption-size
--xh-tour-progress-indicator-gapprogress-indicatorgapdefault--xh-space-2
--xh-tour-pxcontentpadding-inlinedefault--xh-surface-px-md
--xh-tour-pycontentpadding-blockdefault--xh-surface-py-sm
--xh-tour-radiuscontentborder-radiusdefault--xh-shape-overlay
--xh-tour-shadowcontentbox-shadowdefault--xh-material-elevated-shadow
--xh-tour-skip-trigger-pxnext-trigger
prev-trigger
skip-trigger
padding-inlinedefault--xh-_action-profile-padding-inline
--xh-tour-spotlight-layerspotlightz-indexdefault--xh-_layer
--xh-tour-spotlight-radiusspotlightborder-radiusdefault--xh-_tour-spotlight-radius
--xh-tour-spotlight-ringspotlightbox-shadowdefault--xh-_tour-spotlight-ring
--xh-tour-spotlight-shroudspotlightbox-shadowdimmed--xh-bg-overlay
--xh-tour-title-fgtitlecolordefault--xh-fg-default
--xh-tour-title-font-sizetitlefont-sizedefault--xh-text-heading-3-size
--xh-tour-title-font-weighttitlefont-weightdefault--xh-text-heading-3-weight

Released under The MIT License