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

查看生态总览
Skip to content

BackTop ​

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="back-top": root · trigger

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-back-top>
Vue componentsXhBackTopRoot XhBackTopTrigger
ComposableuseBackTop
State machinebackTopMachine
Skin@xihan-ui/styles/back-top.css

Props ​

PropTypeRequired
visibilityHeightnumber
behaviorBackTopBehavior
translationsPartial<BackTopTranslations>
variantActionVariant
toneTone
sizeSize
onVisibilityChange(details: BackTopVisibilityChangeDetails) => void

Events ​

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

EventPayload
visibility-changeBackTopVisibilityChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhBackTopRootdefaultBackTopRootSlotProps

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
XhBackTopRoottarget() => HTMLElement | null
XhBackTopRootchildrenSlotChildren<BackTopRootSlotProps>

State ​

Public state is written to data-state.

PartValues
root'visible' | 'hidden'
trigger'visible' | 'hidden'

The following names are internal to the state machine.

States: hidden · visible

Events: SCROLL.RESOLVE · TRIGGER.CLICK · PRESS.START · PRESS.END · TRIGGER.RENDERED

Guards: shouldShow · shouldHide

connect API ​

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

MemberType
visibleboolean
scrollToTop() => void
getRootProps() => T['element']
getTriggerProps() => T['button']

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 / Spaceback-top.kbd.activate
Enter / Spaceback-top.kbd.press
Tab / Shift+Tabback-top.kbd.tab

ARIA ​

These attributes are produced by connect.

PartAttributeValue
triggeraria-labeltranslations.trigger

Style reference ​

Skin ​

@xihan-ui/styles/back-top.css is written against [data-scope="back-top"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-back-top in place of data-scope (same specificity) and sits in the xihan.components layer. 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-sizeprops.size
rootdata-state'visible' | 'hidden'
rootdata-toneprops.tone
rootdata-variantprops.variant
triggerdata-pressed'' (present only while the condition holds)
triggerdata-state'visible' | 'hidden'
triggerdata-xh-action-control''
triggerdata-xh-action-display'always'
triggerdata-xh-action-profile'floating'
triggerdata-xh-action-sizeprops.size
triggerdata-xh-action-variantprops.variant
triggerdata-xh-ink-surface'' (present only while the condition holds)
triggerdata-xh-liquid''
triggerdata-xh-material'frosted' | undefined

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-back-top-bgroot
trigger
--xh-ink-surface
background-color
default
disabled
focus-visible
variant=outline
xh-ink-surface
--xh-_action-variant-bg-disabled
--xh-_action-variant-bg-focus-visible
--xh-_action-variant-bg-rest
--xh-_material-bg
--xh-_material-bg-focus
--xh-back-top-bg-activeroot
trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
variant=outline
--xh-_action-variant-bg-pressed
--xh-_material-bg-pressed
--xh-back-top-bg-hoverroot
trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
variant=outline
--xh-_action-variant-bg-hover
--xh-_material-bg-hover
--xh-back-top-borderroot
trigger
border
border-color
default
disabled
focus-visible
variant=outline
--xh-_action-variant-border-disabled
--xh-_action-variant-border-focus-visible
--xh-_action-variant-border-rest
--xh-_material-border
--xh-back-top-border-hoverroot
trigger
border-colordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
variant=outline
--xh-_action-variant-border-hover
--xh-_action-variant-border-pressed
--xh-_material-border
--xh-back-top-fgroot
trigger
colordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
variant=outline
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-_material-fg
--xh-back-top-icon-sizetrigger--xh-icon-sizedefault--xh-_back-top-glyph-size
--xh-back-top-inset-blockrootinset-block-enddefault--xh-space-6
--xh-back-top-inset-inlinerootinset-inline-enddefault--xh-space-6
--xh-back-top-layerrootz-indexdefault--xh-layer-sticky
--xh-back-top-radiustriggerborder-radiusdefault--xh-_action-profile-radius
--xh-back-top-shadowroot
trigger
box-shadowdefault
disabled
focus-visible
hover
is(:active, [data-pressed])
is(:hover, [data-loading])
loading
not([data-disabled])
not([data-loading])
pressed
variant=outline
--xh-_material-shadow
none
--xh-back-top-sizetriggerblock-size
inline-size
min-inline-size
default
xh-action-profile=floating
--xh-_back-top-size

Released under The MIT License