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

查看生态总览
Skip to content

DownloadTrigger ​

General 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="download-trigger": root

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-download-trigger>
Vue componentsXhDownloadTrigger
ComposableuseDownloadTrigger
State machinedownloadTriggerMachine
Skin@xihan-ui/styles/download-trigger.css

Props ​

PropTypeRequired
dataDownloadTriggerData
fileNamestring
mimeTypestring
disabledboolean
variantActionVariant
toneTone
sizeSize
translationsPartial<DownloadTriggerTranslations>
onDownloadComplete(details: DownloadTriggerCompleteDetails) => void
onDownloadError(details: DownloadTriggerErrorDetails) => void

Events ​

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

EventPayload
download-completeDownloadTriggerCompleteDetails
download-errorDownloadTriggerErrorDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhDownloadTriggerdefaultDownloadTriggerSlotProps

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
XhDownloadTriggerchildrenSlotChildren<DownloadTriggerSlotProps>

State ​

Public state is written to data-state.

PartValues
root'idle' | 'preparing'

The following names are internal to the state machine.

States: idle · preparing

Events: DOWNLOAD.TRIGGER · DOWNLOAD.SUCCESS · DOWNLOAD.ERROR · PRESS.START · PRESS.END

Guards: isDisabled · canPress

connect API ​

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

MemberType
statusDownloadTriggerStatus
preparingboolean
disabledboolean
fileNamestring
download() => void
getRootProps() => 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 / Spacedownload-trigger.kbd.activate
Enter / Spacedownload-trigger.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-busy'true' | undefined
rootaria-disabled'true' | undefined
rootaria-labelprops.translations.trigger

Style reference ​

Skin ​

@xihan-ui/styles/download-trigger.css is written against [data-scope="download-trigger"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-download-trigger 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-disabled'' (present only while the condition holds)
rootdata-loading'' (present only while the condition holds)
rootdata-pressed'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-state'idle' | 'preparing'
rootdata-toneprops.tone
rootdata-variantprops.variant
rootdata-xh-action-control''
rootdata-xh-action-display'always'
rootdata-xh-action-profile'text'
rootdata-xh-action-sizeprops.size
rootdata-xh-action-variantprops.variant
rootdata-xh-ink-surface'' (present only while the condition holds)
rootdata-xh-loading-ring'overlay'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-download-trigger-bgroot--xh-ink-surface
background-color
default
focus-visible
loading
xh-ink-surface
--xh-_action-variant-bg-focus-visible
--xh-_action-variant-bg-loading
--xh-_action-variant-bg-rest
--xh-download-trigger-bg-activerootbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-download-trigger-bg-disabledroot--xh-ink-surface
background-color
disabled
xh-ink-surface
--xh-_action-variant-bg-disabled
--xh-download-trigger-bg-hoverrootbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-download-trigger-borderrootborder
border-color
default
focus-visible
--xh-_action-variant-border-focus-visible
--xh-_action-variant-border-rest
--xh-download-trigger-border-disabledrootborder-colordisabled--xh-_action-variant-border-disabled
--xh-download-trigger-border-hoverrootborder-colordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-border-hover
--xh-_action-variant-border-pressed
--xh-download-trigger-fgrootborder
border-color
color
@media (prefers-reduced-motion: reduce)
@media print
default
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
motion=reduce
not([data-disabled])
not([data-loading])
pressed
where([data-motion='reduce'])
xh-loading-ring
xh-loading-ring=overlay
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-loading
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-download-trigger-font-sizerootfont-sizedefault--xh-_action-profile-font-size
--xh-download-trigger-font-weightrootfont-weightdefault--xh-text-label-weight
--xh-download-trigger-gaprootgapdefault--xh-_action-profile-gap
--xh-download-trigger-hrootblock-sizedefault--xh-_action-profile-visual-size
--xh-download-trigger-icon-sizeroot--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-download-trigger-loading-durationrootanimationxh-loading-ring--xh-motion-loop-spin
--xh-download-trigger-loading-fgrootborder
border-color
@media (prefers-reduced-motion: reduce)
@media print
motion=reduce
where([data-motion='reduce'])
xh-loading-ring
xh-loading-ring=overlay
--xh-download-trigger-fg
--xh-download-trigger-pxrootpadding-inlinedefault--xh-_action-profile-padding-inline
--xh-download-trigger-radiusrootborder-radiusdefault--xh-shape-control
--xh-download-trigger-shadow-hoverrootbox-shadowdisabled
hover
loading
not([data-disabled])
not([data-loading])
none

Released under The MIT License