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

查看生态总览
Skip to content

TagGroup ​

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="tag-group": root · label · list · cell · item-indicator

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-tag-group>
Vue componentsXhTagGroupCell XhTagGroupItem XhTagGroupItemDeleteTrigger XhTagGroupItemIndicator XhTagGroupItemText XhTagGroupLabel XhTagGroupList XhTagGroupRoot
ComposableuseTagGroup
State machinetagGroupMachine
Skin@xihan-ui/styles/tag-group.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
collectionTagGroupNode[]
valuestring | string[]
defaultValuestring | string[]
selectionModeTagGroupSelectionMode
deletableboolean
disabledboolean
readOnlyboolean
invalidboolean
requiredboolean
loopboolean
dirDirection
orientationOrientation
typeaheadboolean
variantTagVariant
toneTone
sizeSize
onValueChange(details: TagGroupValueChangeDetails) => void
onItemDelete(details: TagGroupItemDeleteDetails) => void
translationsPartial<TagGroupTranslations>

TagGroupNode ​

Elements of collection.

FieldTypeRequired
valuestringYes
labelstring
disabledboolean
deletableboolean

Events ​

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

EventPayload
value-changeTagGroupValueChangeDetails
item-deleteTagGroupItemDeleteDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhTagGroupRootdefaultTagGroupRootSlotProps
XhTagGroupRootlabel—
XhTagGroupRootitemTagGroupNodeMeta

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
XhTagGroupItemvaluestringYes
XhTagGroupItemdisabledboolean
XhTagGroupItemdeletableboolean
XhTagGroupRootlabelReactNode
XhTagGroupRootrenderItem(node: TagGroupNodeMeta) => ReactNode
XhTagGroupRootchildrenSlotChildren<TagGroupRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · ITEM.SELECT · ITEM.TOGGLE · ITEM.FOCUS · ITEM.DELETE · LIST.BLUR · PRESS.START · PRESS.END · LIST.TRACKED

Guards: canPress

connect API ​

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

MemberType
valuestring[]
collectionreadonly TagGroupNodeMeta[]
selectionModeTagGroupSelectionMode
focusedValuestring | null
disabledboolean
readOnlyboolean
invalidboolean
requiredboolean
deletableboolean
isSelected(value: string) => boolean
setValue(next: string[]) => void
select(value: string) => void
toggle(value: string) => void
deleteItem(value: string) => void
getRootProps() => T['element']
getLabelProps() => T['element']
getListProps() => T['element']
getItemProps(props: TagGroupItemProps) => T['element']
getCellProps(props: TagGroupItemProps) => T['element']
getItemIndicatorProps(props: TagGroupItemProps) => T['element']
getItemTextProps(props: TagGroupItemProps) => T['element']
getItemDeleteTriggerProps(props: TagGroupItemProps) => 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
Tab / Shift+Tabtag-group.kbd.tab
ArrowRighttag-group.kbd.next
ArrowLefttag-group.kbd.prev
Hometag-group.kbd.first
Endtag-group.kbd.last
Enter / Spacetag-group.kbd.select
Enter / Spacetag-group.kbd.toggle
Ctrl+A / Cmd+Atag-group.kbd.select-all
Delete / Backspacetag-group.kbd.delete
any single printable charactertag-group.kbd.typeahead

ARIA ​

These attributes are produced by connect.

PartAttributeValue
listaria-disabled'true' | 'false'
listaria-invalid'true' | 'false'
listaria-labelprops.ariaLabel
listaria-labelledbyid of the label part | undefined
listaria-multiselectable'true' | 'false'
listaria-readonly'true' | 'false'
listrole'grid'
cellrole'gridcell'
item-indicatoraria-hidden'true'
itemaria-disabled'true' | 'false'
itemaria-selected'true' | 'false' | undefined
itemrole'row'

Style reference ​

Skin ​

@xihan-ui/styles/tag-group.css is written against [data-scope="tag-group"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-tag-group 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-orientationprops.orientation
rootdata-readonly'' (present only while the condition holds)
rootdata-required'' (present only while the condition holds)
labeldata-disabled'' (present only while the condition holds)
listdata-disabled'' (present only while the condition holds)
listdata-instant'' (present only while the condition holds)
listdata-invalid'' (present only while the condition holds)
listdata-orientationprops.orientation
listdata-required'' (present only while the condition holds)
celldata-disabled'' (present only while the condition holds)
celldata-highlighted'' (present only while the condition holds)
celldata-selected'' (present only while the condition holds)
item-indicatordata-disabled'' (present only while the condition holds)
item-indicatordata-highlighted'' (present only while the condition holds)
item-indicatordata-selected'' (present only while the condition holds)
itemdata-deletable'' (present only while the condition holds)
itemdata-disabled'' (present only while the condition holds)
itemdata-highlighted'' (present only while the condition holds)
itemdata-selectable'' (present only while the condition holds)
itemdata-selected'' (present only while the condition holds)

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-tag-group-gaprootgapdefault--xh-space-2
--xh-tag-group-item-bg-hoverlist
root
backgrounddisabled
highlighted
is(:hover, [data-highlighted])
not([data-disabled])
not([data-tone])
not([data-variant='solid'])
tone
variant=ghost
variant=solid
--xh-_tone-subtle-hover
--xh-bg-subtle
--xh-bg-subtle-hover
--xh-tag-group-item-bg-pressedlist
root
backgrounddisabled
is(:active, [data-pressed])
not([data-disabled])
not([data-tone])
not([data-variant='solid'])
pressed
selectable
tone
variant=ghost
variant=solid
--xh-_tone-subtle-active
--xh-bg-subtle-active
--xh-bg-subtle-hover
--xh-tag-group-item-bg-pressed-solidlist
root
backgrounddisabled
is(:active, [data-pressed])
not([data-disabled])
pressed
selectable
tone
variant=solid
--xh-_tone-active
--xh-bg-brand-active
--xh-tag-group-item-border-invalidlist
root
--xh-tag-borderinvalid--xh-border-invalid
--xh-tag-group-item-indicator-fgitem-indicator
root
colordefault
variant=solid
--xh-_tone-fg
currentColor
--xh-tag-group-item-indicator-sizeitem-indicator--xh-icon-sizedefault--xh-glyph-size-text
--xh-tag-group-label-fglabelcolordefault--xh-fg-muted
--xh-tag-group-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-tag-group-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-tag-group-list-gaplistgapdefault--xh-space-2

Released under The MIT License