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

查看生态总览
Skip to content

Transfer ​

Data entry 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="transfer": root · hidden-input · source-panel · target-panel · panel-header · panel-title · panel-count · search · list · group · group-label · item · item-text · item-description · item-suffix · item-checkbox · empty · loading · to-target-trigger · to-source-trigger · select-all-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-transfer>
Vue componentsXhTransferEmpty XhTransferGroup XhTransferGroupLabel XhTransferItem XhTransferItemCheckbox XhTransferItemDescription XhTransferItemSuffix XhTransferItemText XhTransferList XhTransferLoading XhTransferPanelCount XhTransferPanelHeader XhTransferPanelTitle XhTransferRoot XhTransferSearch XhTransferSelectAllTrigger XhTransferSourcePanel XhTransferTargetPanel XhTransferToSourceTrigger XhTransferToTargetTrigger
ComposableuseTransfer
State machinetransferMachine
Skin@xihan-ui/styles/transfer.css

Props ​

PropTypeRequired
collectionTransferItem[]
virtualizersPartial<Record<TransferSide, CollectionVirtualizer>>
valuestring[]
defaultValuestring[]
namestring
formstring
selectionstring[]
defaultSelectionstring[]
searchableboolean
filterTransferFilter
pageSizenumber
ariaLabelstring
disabledboolean
readOnlyboolean
invalidboolean
requiredboolean
loadingboolean
toneTone
sizeSize
oneWayboolean
loopboolean
dirDirection
translationsPartial<TransferTranslations>
onValueChange(details: TransferValueChangeDetails) => void
onSelectionChange(details: TransferSelectionChangeDetails) => void

TransferItem ​

Elements of collection.

FieldTypeRequired
valuestringYes
labelstringYes
disabledboolean
toneTone
descriptionstring

Events ​

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

EventPayload
value-changeTransferValueChangeDetails
selection-changeTransferSelectionChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhTransferRootdefaultTransferRootSlotProps

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
XhTransferGroupvaluestringYes
XhTransferItemvaluestringYes
XhTransferRootchildrenSlotChildren<TransferRootSlotProps>

State ​

Public state is written to data-state.

PartValues
item'checked' | 'unchecked'
item-text'checked' | 'unchecked'
item-description'checked' | 'unchecked'
item-suffix'checked' | 'unchecked'
item-checkbox'checked' | 'unchecked'
select-all-triggeritemState(item)

The following names are internal to the state machine.

States: idle

Events: FORM.RESET · VALUE.SET · SELECTION.SET · ITEM.TOGGLE · SIDE.TOGGLE_ALL · ITEMS.MOVE · SEARCH.SET · PAGE.SET · ITEM.FOCUS · LIST.BLUR · PRESS.START · PRESS.END

Guards: canPress

connect API ​

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

MemberType
collectionreadonly TransferItem[]
valuestring[]
selectionstring[]
disabledboolean
readOnlyboolean
invalidboolean
requiredboolean
oneWayboolean
searchableboolean
translationsTransferTranslations
visibleItems(side: TransferSide) => readonly TransferItem[]
filteredItems(side: TransferSide) => readonly TransferItem[]
pageSizenumber | undefined
page(side: TransferSide) => number
pageCount(side: TransferSide) => number
setPage(side: TransferSide, page: number) => void
checkedValues(side: TransferSide) => string[]
checkState(side: TransferSide) => TransferCheckState
query(side: TransferSide) => string
canMove(to: TransferSide) => boolean
isChecked(value: string) => boolean
sideOf(value: string) => TransferSide
setValue(next: string[]) => void
setSelection(next: string[]) => void
setQuery(side: TransferSide, query: string) => void
toggle(value: string, options?: { extend?: boolean }) => void
toggleAll(side: TransferSide) => void
move(to: TransferSide) => void
getRootProps() => T['element']
getHiddenInputProps(props?: { value: string }) => T['input']
getPanelProps(props: TransferPanelProps) => T['element']
getPanelHeaderProps(props: TransferPanelProps) => T['element']
getPanelTitleProps(props: TransferPanelProps) => T['element']
getPanelCountProps(props: TransferPanelProps) => T['element']
getSearchProps(props: TransferPanelProps) => T['input']
getListProps(props: TransferPanelProps) => T['element']
getSelectAllTriggerProps(props: TransferPanelProps) => T['button']
getEmptyProps(props: TransferPanelProps) => T['element']
getLoadingProps(props: TransferPanelProps) => T['element']
getGroupProps(props: TransferGroupProps) => T['element']
getGroupLabelProps(props: TransferGroupProps) => T['element']
getItemProps(props: TransferItemProps) => T['element']
getItemTextProps(props: TransferItemProps) => T['element']
getItemDescriptionProps(props: TransferItemProps) => T['element']
getItemSuffixProps(props: TransferItemProps) => T['element']
getItemCheckboxProps(props: TransferItemProps) => T['element']
getToTargetTriggerProps() => T['button']
getToSourceTriggerProps() => 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 / Spacetransfer.kbd.press
Tab / Shift+Tabtransfer.kbd.tab
ArrowDowntransfer.kbd.next
ArrowUptransfer.kbd.prev
Hometransfer.kbd.first
Endtransfer.kbd.last
Space / Enter / Ctrl+Spacetransfer.kbd.toggle
Shift+ArrowDown / Shift+ArrowUptransfer.kbd.extend
Ctrl+A / Cmd+Atransfer.kbd.select-all
ArrowRight / ArrowLefttransfer.kbd.move
Enter / Spacetransfer.kbd.trigger
Enter / Spacetransfer.kbd.select-all-trigger

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-labelprops.ariaLabel
rootrole'group' | undefined
hidden-inputaria-hidden'true'
searcharia-controlslistId[panel.side]
searcharia-labelledbytitleId[panel.side]
listaria-busy'true' | undefined
listaria-disabled'true' | 'false'
listaria-invalid'true' | 'false'
listaria-labelledbytitleId[panel.side]
listaria-multiselectable'true' | 'false'
listaria-readonly'true' | 'false'
listaria-required'true' | 'false' | undefined
listrole'listbox'
grouparia-labelledbyid of the group-label part
grouprole'group'
itemaria-disabled'true' | 'false'
itemaria-selected'true' | 'false'
itemrole'option'
item-checkboxaria-hidden'true'
to-target-triggeraria-controlslistId.target
to-target-triggeraria-labellabel.toTarget
to-source-triggeraria-controlslistId.source
to-source-triggeraria-labellabel.toSource
select-all-triggeraria-checked'true' | 'mixed' | 'false'
select-all-triggeraria-controlslistId[panel.side]
select-all-triggerrole'checkbox'

Style reference ​

Skin ​

@xihan-ui/styles/transfer.css is written against [data-scope="transfer"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-transfer 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-invalid'' (present only while the condition holds)
rootdata-loading'' (present only while the condition holds)
rootdata-one-way'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
rootdata-required'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-toneprops.tone
panel-headerdata-disabled'' (present only while the condition holds)
panel-headerdata-sidepanel.side
panel-titledata-sidepanel.side
panel-countdata-checked-countString(checked[panel.side].length)
panel-countdata-countString(filtered[panel.side].length)
panel-countdata-sidepanel.side
searchdata-sidepanel.side
searchdata-xh-field-input''
listdata-disabled'' (present only while the condition holds)
listdata-invalid'' (present only while the condition holds)
listdata-readonly'' (present only while the condition holds)
listdata-sidepanel.side
listdata-xh-virtualized'' (present only while the condition holds)
groupdata-disabled'' (present only while the condition holds)
groupdata-sidegroup.side
group-labeldata-disabled'' (present only while the condition holds)
group-labeldata-sidegroup.side
itemdata-disabled'' (present only while the condition holds)
itemdata-highlighted'' (present only while the condition holds)
itemdata-pressed'' (present only while the condition holds)
itemdata-sideitem.side
itemdata-state'checked' | 'unchecked'
itemdata-toneindex.get(v)?.tone
itemdata-xh-collection-context'page'
itemdata-xh-collection-item''
itemdata-xh-collection-sizeprops.size
item-textdata-disabled'' (present only while the condition holds)
item-textdata-highlighted'' (present only while the condition holds)
item-textdata-sideitem.side
item-textdata-state'checked' | 'unchecked'
item-textdata-xh-collection-slot'text'
item-descriptiondata-disabled'' (present only while the condition holds)
item-descriptiondata-highlighted'' (present only while the condition holds)
item-descriptiondata-sideitem.side
item-descriptiondata-state'checked' | 'unchecked'
item-descriptiondata-xh-collection-slot'description'
item-suffixdata-disabled'' (present only while the condition holds)
item-suffixdata-highlighted'' (present only while the condition holds)
item-suffixdata-sideitem.side
item-suffixdata-state'checked' | 'unchecked'
item-suffixdata-xh-collection-slot'suffix'
item-checkboxdata-disabled'' (present only while the condition holds)
item-checkboxdata-highlighted'' (present only while the condition holds)
item-checkboxdata-sideitem.side
item-checkboxdata-state'checked' | 'unchecked'
item-checkboxdata-xh-check-markstate['data-state']
item-checkboxdata-xh-check-mark-profile'box'
item-checkboxdata-xh-collection-slot'prefix'
emptydata-disabled'' (present only while the condition holds)
emptydata-sidepanel.side
loadingdata-disabled'' (present only while the condition holds)
loadingdata-loading'' (present only while the condition holds)
loadingdata-sidepanel.side
loadingdata-xh-loading-ring''
to-target-triggerdata-disabled'' (present only while the condition holds)
to-target-triggerdata-pressed'' (present only while the condition holds)
to-target-triggerdata-xh-action-control''
to-target-triggerdata-xh-action-display'always'
to-target-triggerdata-xh-action-profile'icon'
to-target-triggerdata-xh-action-size'sm'
to-target-triggerdata-xh-action-variant'subtle'
to-source-triggerdata-disabled'' (present only while the condition holds)
to-source-triggerdata-pressed'' (present only while the condition holds)
to-source-triggerdata-xh-action-control''
to-source-triggerdata-xh-action-display'always'
to-source-triggerdata-xh-action-profile'icon'
to-source-triggerdata-xh-action-size'sm'
to-source-triggerdata-xh-action-variant'subtle'
select-all-triggerdata-disabled'' (present only while the condition holds)
select-all-triggerdata-pressed'' (present only while the condition holds)
select-all-triggerdata-sidepanel.side
select-all-triggerdata-stateitemState(item)
select-all-triggerdata-xh-action-control''
select-all-triggerdata-xh-action-display'always'
select-all-triggerdata-xh-action-profile'text'
select-all-triggerdata-xh-action-size'xs'
select-all-triggerdata-xh-action-variant'ghost'
select-all-triggerdata-xh-check-markitemState(item)
select-all-triggerdata-xh-check-mark-profile'row'
paneldata-disabled'' (present only while the condition holds)
paneldata-sidepanel.side

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-transfer-checkbox-bgitem-checkbox
select-all-trigger
backgrounddefaulttransparent
--xh-transfer-checkbox-bg-checkeditem-checkbox
select-all-trigger
backgroundis([data-state='checked'], [data-state='indeterminate'])
state=checked
state=indeterminate
--xh-_transfer-accent
--xh-transfer-checkbox-bg-disableditem-checkboxbackgrounddisabled--xh-bg-muted
--xh-transfer-checkbox-borderitem-checkbox
select-all-trigger
borderdefault--xh-border-strong
--xh-transfer-checkbox-border-checkeditem-checkbox
select-all-trigger
border-coloris([data-state='checked'], [data-state='indeterminate'])
state=checked
state=indeterminate
--xh-_transfer-accent
--xh-transfer-checkbox-border-disableditem-checkboxborder-colordisabled--xh-border-default
--xh-transfer-checkbox-fgitem-checkbox
select-all-trigger
--xh-check-mark-fg
color
default--xh-_transfer-on-accent
--xh-transfer-checkbox-font-sizeitem-checkbox
select-all-trigger
font-sizedefault--xh-_transfer-box
--xh-transfer-checkbox-radiusitem-checkbox
select-all-trigger
border-radiusdefault--xh-shape-inset
--xh-transfer-checkbox-sizeitem-checkbox
select-all-trigger
--xh-check-mark-box-size
--xh-icon-size
block-size
inline-size
default--xh-_transfer-box
--xh-transfer-empty-fgemptycolordefault--xh-fg-muted
--xh-transfer-empty-font-sizeemptyfont-sizedefault--xh-_transfer-font-size
--xh-transfer-empty-pxemptypadding-inlinedefault--xh-_transfer-px
--xh-transfer-empty-pyemptypadding-blockdefault--xh-space-3
--xh-transfer-fgrootcolordefault--xh-fg-default
--xh-transfer-gaprootgapdefault--xh-space-5
--xh-transfer-group-gapgroupgapdefault--xh-list-option-gap
--xh-transfer-group-label-fggroup-labelcolordefault--xh-fg-muted
--xh-transfer-group-label-font-sizegroup-labelfont-sizedefault--xh-text-caption-size
--xh-transfer-group-label-font-weightgroup-labelfont-weightdefault--xh-font-weight-medium
--xh-transfer-group-label-pxgroup-labelpadding-inlinedefault--xh-_transfer-px
--xh-transfer-group-label-pygroup-labelpadding-blockdefault--xh-space-1
--xh-transfer-group-spacinggroupmargin-block-startdefault--xh-space-1_5
--xh-transfer-icon-sizeitem
root
to-source-trigger
to-target-trigger
--xh-icon-sizedefault
size=lg
size=sm
--xh-_action-profile-glyph-size
--xh-_collection-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-transfer-item-bg-hoveritembackground-colordisabled
error
highlighted
hover
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
--xh-bg-subtle
--xh-transfer-item-bg-presseditembackground-colordisabled
error
is(:active, [data-pressed])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
--xh-bg-subtle-hover
--xh-transfer-item-bg-selecteditembackground-colordisabled
error
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
selected
xh-collection-context=page
--xh-bg-brand-subtle
--xh-transfer-item-fgitemcolordefault
disabled
error
highlighted
hover
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
--xh-fg-default
--xh-transfer-item-fg-selecteditemcolordisabled
error
highlighted
hover
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
selected
xh-collection-context=page
--xh-fg-on-brand-subtle
--xh-transfer-item-font-sizeitemfont-sizedefault--xh-_transfer-font-size
--xh-transfer-item-gapitemgapdefault--xh-_transfer-gap
--xh-transfer-item-hitemmin-block-sizedefault--xh-_transfer-item-h
--xh-transfer-item-leadingitemline-heightdefault--xh-leading-normal
--xh-transfer-item-pxitempadding-inlinedefault--xh-_transfer-px
--xh-transfer-item-pyitempadding-blockdefault--xh-_transfer-item-py
--xh-transfer-item-radiusitemborder-radiusdefault--xh-shape-inset
--xh-transfer-list-gaplistgapdefault--xh-list-option-gap
--xh-transfer-list-hlistblock-sizedefault--xh-viewport-h-sm
--xh-transfer-list-pxlistpadding-inlinedefault--xh-space-1
--xh-transfer-list-pylistpadding-blockdefault--xh-space-0
--xh-transfer-loading-fgloadingcolordefault--xh-fg-muted
--xh-transfer-loading-font-sizeloadingfont-sizedefault--xh-_transfer-font-size
--xh-transfer-loading-pxloadingpadding-inlinedefault--xh-_transfer-px
--xh-transfer-loading-pyloadingpadding-blockdefault--xh-space-3
--xh-transfer-panel-bgsource-panel
target-panel
backgrounddefault--xh-bg-surface
--xh-transfer-panel-bg-disabledsource-panel
target-panel
backgrounddisabled--xh-bg-muted
--xh-transfer-panel-bordersource-panel
target-panel
borderdefault--xh-border-default
--xh-transfer-panel-border-invalidroot
source-panel
target-panel
border-colorinvalid
is([data-scope='transfer'][data-part='source-panel'], [data-scope='transfer'][data-part='target-panel'])
--xh-border-invalid
--xh-transfer-panel-count-fgpanel-countcolordefault--xh-fg-subtle
--xh-transfer-panel-count-font-sizepanel-countfont-sizedefault--xh-text-caption-size
--xh-transfer-panel-header-bgpanel-headerbackgrounddefault--xh-bg-muted
--xh-transfer-panel-header-gappanel-headergapdefault--xh-_transfer-gap
--xh-transfer-panel-header-pxpanel-headerpadding-inlinedefault--xh-_transfer-px
--xh-transfer-panel-header-pypanel-headerpadding-blockdefault--xh-space-3
--xh-transfer-panel-radiussource-panel
target-panel
border-radiusdefault--xh-shape-surface
--xh-transfer-panel-title-fgpanel-titlecolordefault--xh-fg-default
--xh-transfer-panel-title-font-sizepanel-titlefont-sizedefault--xh-text-label-size
--xh-transfer-panel-title-font-weightpanel-titlefont-weightdefault--xh-font-weight-medium
--xh-transfer-placeholder-fgsearchcolorplaceholder
xh-field-input
--xh-fg-subtle
--xh-transfer-search-bgsearchbackgrounddefaulttransparent
--xh-transfer-search-bordersearchborder-block-enddefault--xh-material-solid-separator
--xh-transfer-search-fgsearchcolordefault--xh-fg-default
--xh-transfer-search-font-sizesearchfont-sizedefault--xh-_transfer-font-size
--xh-transfer-search-hsearchblock-sizedefault--xh-_transfer-h
--xh-transfer-search-pxsearchpadding-inlinedefault--xh-_transfer-px
--xh-transfer-select-all-bg-hoverselect-all-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-transfer-select-all-bg-pressedselect-all-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-transfer-select-all-fgselect-all-triggercolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-muted
--xh-transfer-select-all-font-sizeselect-all-triggerfont-sizedefault--xh-text-caption-size
--xh-transfer-select-all-gapselect-all-triggergapdefault--xh-control-gap-sm
--xh-transfer-select-all-radiusselect-all-triggerborder-radiusdefault--xh-shape-inset
--xh-transfer-trigger-bgto-source-trigger
to-target-trigger
--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-transfer-trigger-bg-activeto-source-trigger
to-target-trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-transfer-trigger-bg-hoverto-source-trigger
to-target-trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-transfer-trigger-borderto-source-trigger
to-target-trigger
border
border-color
default
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-border-hover
--xh-_action-variant-border-pressed
--xh-_action-variant-border-rest
--xh-transfer-trigger-fgto-source-trigger
to-target-trigger
colordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-transfer-trigger-font-sizeto-source-trigger
to-target-trigger
font-sizedefault--xh-text-label-size
--xh-transfer-trigger-pxto-source-trigger
to-target-trigger
padding-inlinedefault--xh-_action-profile-padding-inline
--xh-transfer-trigger-radiusto-source-trigger
to-target-trigger
border-radiusdefault--xh-shape-circle
--xh-transfer-trigger-shadow-activeto-source-trigger
to-target-trigger
box-shadowdisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
none
--xh-transfer-trigger-shadow-hoverto-source-trigger
to-target-trigger
box-shadowdisabled
hover
loading
not([data-disabled])
not([data-loading])
none
--xh-transfer-trigger-sizeto-source-trigger
to-target-trigger
block-size
inline-size
min-inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size

Released under The MIT License