跳转到内容

Combobox 组合框 ​

将输入框与候选列表结合,用于搜索并选择选项。

用法 ​

搜索并选择城市

组件结构 ​

加粗的是必需部件。

data-scope="combobox":root · label · control · input · trigger · clear-trigger · positioner · content · item · item-prefix · item-text · item-description · item-suffix · item-indicator · group · group-label · empty · loading · hidden-input

示例 ​

多选 ​

选择多个城市

自定义值 ​

选择候选项或输入新值

分组 ​

按分类组织候选项

变体 ​

设置输入框外观

校验状态 ​

标记无效输入

异步候选 ​

查询远程数据

自定义内容 ​

在候选项中显示辅助信息

设计指引 ​

何时使用 ​

  • 选项较多,需要通过输入快速筛选。
  • 候选来自远程数据或允许输入自定义值。

何时不用 ​

  • 选项固定且不多时,使用选择器。
  • 在正文中插入引用时,使用提及。
  • 输入一组自由标签时,使用标签输入。

特性 ​

  • 支持单选、多选、分组和自定义值。
  • 候选可逐条声明语气,失效或需要留意的那条自带该族字色与高亮底。
  • 候选可写副文本,第 2 行放一句解释,与标题同列、走 muted 档。
  • 行首与行尾两格各有逐条钩子:只想加个图标或计数,不必把整条重搭。
  • 输入值、选中值与展开状态均可独立受控。
  • loading 与 empty 分别表示加载和空结果。
  • 支持自定义过滤、异步候选和自定义条目内容。
  • 通过隐藏输入参与原生表单提交。

组合 ​

  • 放进表单字段获得标签、说明与错误信息,字段状态会接到输入框上。
  • 候选列表是常驻的列表框收进浮层的形态;选项固定且不需要输入时换成选择器。
  • 多选时的已选项可用标签组排在输入框前。

最佳实践 ​

  • 为异步查询提供加载和空结果反馈。
  • 远程过滤应使用防抖,并取消过期请求。
  • 允许自定义值时,明确提示 Enter 会采用当前输入。
  • 使用标签说明字段含义,使用占位文本提示搜索方式。

反模式 ​

  • 未经说明就接受候选列表之外的值。
  • 每次按键都立即发起远程请求。

API 参考 ​

产物 ​

层值
自定义元素<xh-combobox>
Vue 组件XhComboboxClearTrigger XhComboboxContent XhComboboxControl XhComboboxEmpty XhComboboxGroup XhComboboxGroupLabel XhComboboxHiddenInput XhComboboxInput XhComboboxItem XhComboboxItemDescription XhComboboxItemIndicator XhComboboxItemPrefix XhComboboxItemSuffix XhComboboxItemText XhComboboxLabel XhComboboxLoading XhComboboxPositioner XhComboboxRoot XhComboboxTrigger
组合式函数useCombobox
状态机comboboxMachine
皮肤@xihan-ui/styles/combobox.css

Props ​

属性类型必填说明
collectionComboboxNode[]候选数据,显示文本与禁用的事实源。过滤仍由调用方完成:传入的即当前应显示的候选。 提供后条目部件只需声明 value,显示文本也不再从 DOM 查询。 未提供时回到文本写在条目中、从 DOM 查询的方式。
valuestring | string[]选中值。提供即受控:cell 直读 prop,写入只发 onValueChange 不落内部值。 单选写为裸串是简写,内部一律归一为数组。
defaultValuestring | string[]
inputValuestring输入框中的字符串。提供即受控,与选中值各自独立。 过滤不由组件完成:调用方用该串筛选条目,把筛选结果重新渲染进来。
defaultInputValuestring
openboolean展开态。提供即受控:内部不再自行修改,只发 onOpenChange。
defaultOpenboolean
namestring表单字段名;hidden-input 按选中值逐个生成同名字段,不使用分隔符编码。
formstring原生表单 ID;显式关联外部表单,提交与 reset 使用同一所有者。
multipleboolean
disabledboolean整个控件禁用:输入框与两个按钮都使用原生 disabled。
readOnlyboolean只读:文字可选可复制,但展开、选中、清空一概不发生。
invalidboolean校验失败:输入框报告 aria-invalid,各角色节点带 data-invalid。
loadingboolean候选加载中:列表报告 aria-busy,显示在途占位、隐藏空态占位。
loopboolean方向键到达末尾是否回绕,默认 true。
placeholderstring输入框占位文字。
translationsPartial<ComboboxTranslations>读屏文案;未提供的键使用英文默认值。
allowCustomValueboolean允许提交候选列表中没有的值(回车与失焦时把输入串本身收为选中值)。
openOnClickboolean点击输入框即展开,默认 false(只有触发按钮与方向键展开)。
inputBehaviorComboboxInputBehavior输入行为,默认 none。
placementPlacement
dirDirection文字方向,默认 ltr。只改写浮层在行内轴上 start 与 end 的落点。
offsetnumber
variantControlVariant形态:outline / subtle / ghost,决定输入行的描边与底色使用方式。默认 outline。
toneTone语气:brand / neutral / success / warning / danger / info,决定聚焦与选中强调使用哪族颜色。
sizeSize尺寸:sm / md / lg,决定输入行高度、内边距与字号档位。
onValueChange(details: ComboboxValueChangeDetails) => voidvalue 变化意图回调;受控时是唯一出口,非受控时随内部写入一并通知。
onInputValueChange(details: ComboboxInputValueChangeDetails) => void输入串变化回调:调用方据此重新过滤候选。
onOpenChange(details: ComboboxOpenChangeDetails) => voidopen 变化意图回调;受控时是唯一出口,非受控时随内部转移一并通知。

ComboboxNode ​

collection 的元素。

字段类型必填说明
valuestring是
labelstring展示文本,也是选中后回填输入框的取字来源;默认回退为 value。
disabledboolean候选禁用:方向键跳过它,点击与回车都不选中它。
toneTone该条候选自身的性质:危险选项写 danger、需要留意的写 warning。不写即与其余候选同档。 只换字色与悬停 / 按下的面,不表达选中与校验;选中的标记与禁用都压过它。 彩字不是唯一通道,要紧的差别仍要配图标或文案。整个组合框的 tone 不下发给候选。
descriptionstring副文本,写入 item-description 部件;未提供时本条不铺该部件。 它是第 2 行的说明,跟着条目走 muted 档,不跟语气;放不下一行的解释才用它, 一句话能说清的写进 label。

事件 ​

自定义元素将载荷放在 detail;Vue 使用同名 emit。

事件载荷说明
value-changeComboboxValueChangeDetails选中集合变化;detail 为 { value: string[] }
input-value-changeComboboxInputValueChangeDetails输入串变化;detail 为 { inputValue: string },作者据此过滤候选
open-changeComboboxOpenChangeDetailsopen 状态变化;detail 为 { open: boolean }

插槽 ​

仅列出带载荷的插槽。

Vue 组件插槽载荷说明
XhComboboxRootdefaultComboboxRootSlotProps
XhComboboxRootlabel—
XhComboboxRootempty—
XhComboboxRootitemComboboxNodeMeta只填条目的文字槽,副文本与首尾两格照旧各归各的
XhComboboxRootitem-prefixComboboxNodeMeta只接管行首那一格,其余槽照旧由数据铺
XhComboboxRootitem-suffixComboboxNodeMeta只接管行尾那一格(计数、徽标、次级图标),其余槽照旧由数据铺

React 适配器 props ​

只列各组件自己声明的那些:继承自 ComponentPropsWithRef 的 DOM 属性不在其中,根组件上与上面 Props 表同名的也不重复列。Vue 的对应物是上面的插槽表。

React 组件属性类型必填说明
XhComboboxGroupvaluestring是
XhComboboxInputasComboboxInputHost输入框渲染为哪个标签,默认 input。 写 textarea 即多行宿主:connect 随之撤销 type、role 与 aria-expanded。
XhComboboxItemvaluestring是
XhComboboxItemdisabledboolean默认交给 connect 查询 collection,写死 false 会覆盖数据中的禁用。
XhComboboxPositionercontainer() => Element | null浮层挂载的容器;未提供时按全局配置,再未提供时挂载到 body。
XhComboboxRootlabelReactNode标题文字。提供后不必再写 label 部件。
XhComboboxRootemptyReactNode无匹配时的提示语。提供后不必再写 empty 部件。
XhComboboxRootclearableboolean自动铺开时是否渲染清空按钮;手写部件模式不使用它,写了节点即可清空。
XhComboboxRootrenderItem(node: ComboboxNodeMeta) => ReactNode每个候选的自定义内容;未提供时使用 collection 中的 label。
XhComboboxRootrenderItemPrefix(node: ComboboxNodeMeta) => ReactNode只接管条目行首那一格;其余槽仍由数据铺。
XhComboboxRootrenderItemSuffix(node: ComboboxNodeMeta) => ReactNode只接管条目行尾那一格;其余槽仍由数据铺。
XhComboboxRootchildrenSlotChildren<ComboboxRootSlotProps>

状态 ​

公开状态写入 data-state。

部件取值
root'open' | 'closed'
control'open' | 'closed'
input'open' | 'closed'
trigger'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'
item'checked' | 'unchecked'
item-prefix'checked' | 'unchecked'
item-text'checked' | 'unchecked'
item-description'checked' | 'unchecked'
item-suffix'checked' | 'unchecked'
item-indicator'checked' | 'unchecked'
empty'open' | 'closed'
loading'open' | 'closed'

以下名称仅用于内部状态机。

状态:open · closed

事件:OPEN · TOGGLE · CLOSE · CONTROLLED.OPEN · CONTROLLED.CLOSE · ESCAPE · INPUT.CHANGE · INPUT.SET · INPUT.BLUR · ITEM.HIGHLIGHT · HIGHLIGHT.CLEAR · ITEM.SELECT · VALUE.COMMIT · VALUE.SET · VALUE.CLEAR · ITEMS.SYNC · FORM.RESET · PRESS.START · PRESS.END

判据:isOpenControlled · isMultiple · hasHighlight · canPress

connect API ​

getXxxProps() 返回对应部件的宿主属性。

成员类型说明
openboolean
collectionreadonly ComboboxNodeMeta[]由 collection 推导的候选元信息,按数据顺序排列;未提供 collection 时为空数组。
valuestring[]选中集合;单选模式下长度 ≤ 1,形状不随模式变化。
inputValuestring输入框中的字符串。
valueTextstring | null单选选中项的显示文本;无选中或多选时为 null。
highlightedValuestring | null高亮候选;收起时为 null。焦点不在它身上,只经 aria-activedescendant 上报。
multipleboolean
disabledboolean
readOnlyboolean
invalidboolean
emptyboolean候选为空(已结算且条数为 0)且当前展开:empty 角色节点据此显示。
canClearboolean清空按钮当前是否可按。
isSelected(value: string) => boolean
setOpen(next: boolean) => void
setValue(next: string[]) => void
setInputValue(next: string) => void
clear() => void
getRootProps() => T['element']
getLabelProps() => T['label']
getControlProps() => T['element']
getInputProps(props?: ComboboxInputProps) => T['input']不传参即单行 input,产出与增加此参数前逐字相同。
getTriggerProps() => T['button']
getClearTriggerProps() => T['button']
getPositionerProps() => T['element']
getContentProps() => T['element']
getGroupProps(props: ComboboxGroupProps) => T['element']
getGroupLabelProps(props: ComboboxGroupProps) => T['element']
getItemProps(props: ComboboxItemProps) => T['element']
getItemPrefixProps(props: ComboboxItemProps) => T['element']
getItemTextProps(props: ComboboxItemProps) => T['element']
getItemDescriptionProps(props: ComboboxItemProps) => T['element']
getItemSuffixProps(props: ComboboxItemProps) => T['element']
getItemIndicatorProps(props: ComboboxItemProps) => T['element']
getEmptyProps() => T['element']
getLoadingProps() => T['element']在途占位:与空态占位同一位置,两者不同时显示:加载期间显示它,空态让位。 与 content 是兄弟,同样不进入 role=listbox。
getHiddenInputProps(props: { value: string }) => T['input']单值表单出口;按 api.value 逐个调用并生成同名 input,零选中不生成提交项。

无障碍 ​

键盘 ​

规格出处:W3C APG

按键生效条件行为
ArrowDownclosed, focus in input展开候选列表并把高亮落到首个可选候选
ArrowUpclosed, focus in input展开候选列表并把高亮落到末个可选候选
Alt+ArrowDownclosed, focus in input展开候选列表但不预选任何候选
ArrowDownopen高亮移到下一个候选(禁用项跳过、尽头按 loop 回绕),焦点不动
ArrowUpopen高亮移到上一个候选(禁用项跳过、尽头按 loop 回绕),焦点不动
Homeopen高亮移到首个可选候选;收起态不接管,光标照常跳到行首
Endopen高亮移到末个可选候选;收起态不接管,光标照常跳到行尾
Enteropen, 有高亮且未禁用选中高亮候选:单选把输入串换成它的文本并收起,多选把它并入集合、清空输入串且不收起
Enteropen, 有高亮且未禁用、未只读、未加载,按住按住期间高亮候选投影 data-pressed,与指针 :active 同一副按压面;抬起或失焦撤下,候选随浮层收起一并撤下。展开钮与清空钮在焦点落到自己身上时由 Enter / Space 按住投影,没有东西可清时清空钮不进
Enteropen, 无高亮且 allowCustomValue把输入串本身收成选中值
Escapeopen先清除高亮;高亮已空时才收起列表,选中值不变
Alt+ArrowUpopen收起列表,选中值不变
Tab / Shift+Tabopen收起列表且不拦按键,焦点按 Tab 序列自然离开
Backspacemultiple, 输入串为空且已有选中删掉最后一个已选项
可打印字符focus in input改写输入串并展开列表;过滤由调用方按 onInputValueChange 自己做

ARIA ​

以下属性由 connect 生成。

部件属性值
inputaria-activedescendantitem 部件的 id | undefined
inputaria-autocomplete'both' | 'list'
inputaria-controlscontent 部件的 id
inputaria-expandedundefined | 'true' | 'false'
inputaria-haspopup'listbox'
inputaria-invalid'true' | 'false'
inputaria-labelledbylabel 部件的 id
inputroleundefined | 'combobox'
triggeraria-controlscontent 部件的 id
triggeraria-labelprops.translations.trigger
clear-triggeraria-labelprops.translations.clearTrigger
contentaria-busy'true' | undefined
contentaria-hidden!open || undefined
contentaria-labelledbylabel 部件的 id
contentaria-multiselectable'true' | 'false'
contentrole'listbox'
itemaria-disabled'true' | 'false'
itemaria-selected'true' | 'false'
itemrole'option'
item-prefixaria-hidden'true'
item-indicatoraria-hidden'true'
grouparia-labelledbygroup-label 部件的 id
grouprole'group'
emptyrole'status'
loadingrole'status'

样式参考 ​

皮肤 ​

@xihan-ui/styles/combobox.css 使用 [data-scope="combobox"][data-part="root"] 部件选择器,位于 xihan.components 层。覆盖样式使用 xihan.overrides。

数据属性 ​

由 connect 生成;条件不成立时不输出无值属性。

部件属性值
rootdata-disabled''(条件成立时才出现)
rootdata-invalid''(条件成立时才出现)
rootdata-loading''(条件成立时才出现)
rootdata-readonly''(条件成立时才出现)
rootdata-sizeprops.size
rootdata-state'open' | 'closed'
rootdata-toneprops.tone
rootdata-variantprops.variant
labeldata-disabled''(条件成立时才出现)
controldata-disabled''(条件成立时才出现)
controldata-invalid''(条件成立时才出现)
controldata-readonly''(条件成立时才出现)
controldata-state'open' | 'closed'
controldata-variantprops.variant
controldata-xh-field-chrome''
controldata-xh-field-sizeprops.size
inputdata-disabled''(条件成立时才出现)
inputdata-invalid''(条件成立时才出现)
inputdata-readonly''(条件成立时才出现)
inputdata-state'open' | 'closed'
inputdata-xh-field-input''
inputdata-xh-field-layout'textarea' | 'single-line'
triggerdata-disabled''(条件成立时才出现)
triggerdata-pressed''(条件成立时才出现)
triggerdata-state'open' | 'closed'
triggerdata-xh-action-control''
triggerdata-xh-action-display'always'
triggerdata-xh-action-profile'field-inset'
triggerdata-xh-action-sizeprops.size
triggerdata-xh-action-variant'ghost'
clear-triggerdata-pressed''(条件成立时才出现)
clear-triggerdata-xh-action-control''
clear-triggerdata-xh-action-display'has-value'
clear-triggerdata-xh-action-has-value''(条件成立时才出现)
clear-triggerdata-xh-action-profile'field-inset'
clear-triggerdata-xh-action-sizeprops.size
clear-triggerdata-xh-action-variant'ghost'
positionerdata-hidden''(条件成立时才出现)
positionerdata-placement定位引擎算出的实际落位
positionerdata-positioned''(条件成立时才出现)
positionerdata-sizeprops.size
positionerdata-state'open' | 'closed'
positionerdata-toneprops.tone
positionerdata-variantprops.variant
contentdata-placement定位引擎算出的实际落位
contentdata-state'open' | 'closed'
contentdata-xh-material'frosted'
itemdata-disabled''(条件成立时才出现)
itemdata-highlighted''(条件成立时才出现)
itemdata-pressed''(条件成立时才出现)
itemdata-state'checked' | 'unchecked'
itemdata-tonemetaOf.get(item.value)?.tone
itemdata-xh-collection-context'overlay'
itemdata-xh-collection-item''
itemdata-xh-collection-sizeprops.size
item-prefixdata-disabled''(条件成立时才出现)
item-prefixdata-highlighted''(条件成立时才出现)
item-prefixdata-state'checked' | 'unchecked'
item-prefixdata-xh-collection-slot'prefix'
item-textdata-disabled''(条件成立时才出现)
item-textdata-highlighted''(条件成立时才出现)
item-textdata-state'checked' | 'unchecked'
item-textdata-xh-collection-slot'text'
item-descriptiondata-disabled''(条件成立时才出现)
item-descriptiondata-highlighted''(条件成立时才出现)
item-descriptiondata-state'checked' | 'unchecked'
item-descriptiondata-xh-collection-slot'description'
item-suffixdata-disabled''(条件成立时才出现)
item-suffixdata-highlighted''(条件成立时才出现)
item-suffixdata-state'checked' | 'unchecked'
item-suffixdata-xh-collection-slot'suffix'
item-indicatordata-disabled''(条件成立时才出现)
item-indicatordata-highlighted''(条件成立时才出现)
item-indicatordata-state'checked' | 'unchecked'
item-indicatordata-xh-collection-slot'indicator'
emptydata-state'open' | 'closed'
loadingdata-state'open' | 'closed'

CSS 变量 ​

本组件公开覆盖槽由独立皮肤的实际消费位生成;默认来源、作用部件和状态均与 CSS 同源。

变量部件CSS 属性状态默认来源说明
--xh-combobox-action-bgclear-trigger
trigger
--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-restcombobox 的 clear-trigger、trigger 部件 --xh-ink-surface、background-color 覆盖槽。
--xh-combobox-action-bg-activeclear-trigger
trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressedcombobox 的 clear-trigger、trigger 部件 background-color 覆盖槽。
--xh-combobox-action-bg-hoverclear-trigger
trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hovercombobox 的 clear-trigger、trigger 部件 background-color 覆盖槽。
--xh-combobox-action-fgclear-trigger
trigger
colordefault--xh-fg-mutedcombobox 的 clear-trigger、trigger 部件 color 覆盖槽。
--xh-combobox-action-fg-hoverclear-trigger
trigger
colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-fg-defaultcombobox 的 clear-trigger、trigger 部件 color 覆盖槽。
--xh-combobox-action-font-sizeclear-trigger
trigger
font-sizedefault--xh-text-secondary-sizecombobox 的 clear-trigger、trigger 部件 font-size 覆盖槽。
--xh-combobox-action-radiusclear-trigger
trigger
border-radiusdefault--xh-shape-insetcombobox 的 clear-trigger、trigger 部件 border-radius 覆盖槽。
--xh-combobox-action-sizeclear-trigger
trigger
block-size
inline-size
min-inline-size
default
xh-action-profile=field-inset
--xh-_action-profile-visual-sizecombobox 的 clear-trigger、trigger 部件 block-size、inline-size、min-inline-size 覆盖槽。
--xh-combobox-content-backdropcontent-webkit-backdrop-filter
backdrop-filter
xh-material=frosted--xh-_material-backdropcombobox 的 content 部件 -webkit-backdrop-filter、backdrop-filter 覆盖槽。
--xh-combobox-content-bgcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-bgcombobox 的 content 部件 background 覆盖槽。
--xh-combobox-content-bordercontentbordernot([data-xh-action-control])
xh-material=frosted
--xh-_material-bordercombobox 的 content 部件 border 覆盖槽。
--xh-combobox-content-fgcontentcolornot([data-xh-action-control])
xh-material=frosted
--xh-_material-fgcombobox 的 content 部件 color 覆盖槽。
--xh-combobox-content-gapcontentgapdefault--xh-list-option-gapcombobox 的 content 部件 gap 覆盖槽。
--xh-combobox-content-highlightcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-highlightcombobox 的 content 部件 background 覆盖槽。
--xh-combobox-content-max-hcontentmax-block-sizedefault--xh-overlay-max-hcombobox 的 content 部件 max-block-size 覆盖槽。
--xh-combobox-content-max-wcontentmax-inline-sizedefault--xh-overlay-max-wcombobox 的 content 部件 max-inline-size 覆盖槽。
--xh-combobox-content-min-hcontentmin-block-sizedefault--xh-_combobox-hcombobox 的 content 部件 min-block-size 覆盖槽。
--xh-combobox-content-min-wcontentmin-inline-sizedefault--xh-overlay-min-wcombobox 的 content 部件 min-inline-size 覆盖槽。
--xh-combobox-content-pxcontentpadding-inlinedefault--xh-space-1combobox 的 content 部件 padding-inline 覆盖槽。
--xh-combobox-content-pycontentpadding-blockdefault--xh-space-1combobox 的 content 部件 padding-block 覆盖槽。
--xh-combobox-content-radiuscontentborder-radiusdefault--xh-shape-overlaycombobox 的 content 部件 border-radius 覆盖槽。
--xh-combobox-content-shadowcontentbox-shadownot([data-xh-action-control])
xh-material=frosted
--xh-_material-shadowcombobox 的 content 部件 box-shadow 覆盖槽。
--xh-combobox-control-bgcontrolbackground-colorxh-field-chrome--xh-_field-variant-bg-restcombobox 的 control 部件 background-color 覆盖槽。
--xh-combobox-control-bg-disabledcontrolbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabledcombobox 的 control 部件 background-color 覆盖槽。
--xh-combobox-control-bg-hovercontrolbackground-colordisabled
hover
invalid
loading
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-bg-hovercombobox 的 control 部件 background-color 覆盖槽。
--xh-combobox-control-bg-readonlycontrolbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-onlycombobox 的 control 部件 background-color 覆盖槽。
--xh-combobox-control-bordercontrolborderxh-field-chrome--xh-_field-variant-border-restcombobox 的 control 部件 border 覆盖槽。
--xh-combobox-control-border-focuscontrolborder-colordisabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focuscombobox 的 control 部件 border-color 覆盖槽。
--xh-combobox-control-border-hovercontrolborder-colordisabled
hover
invalid
loading
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-border-hovercombobox 的 control 部件 border-color 覆盖槽。
--xh-combobox-control-border-invalidcontrolborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalidcombobox 的 control 部件 border-color 覆盖槽。
--xh-combobox-control-fgcontrol
input
colorxh-field-chrome
xh-field-input
--xh-fg-defaultcombobox 的 control、input 部件 color 覆盖槽。
--xh-combobox-control-gapcontrolgapxh-field-chrome--xh-_combobox-gapcombobox 的 control 部件 gap 覆盖槽。
--xh-combobox-control-hcontrolblock-size
min-block-size
has([data-xh-field-input][data-xh-field-layout='multi-tag'])
has([data-xh-field-input][data-xh-field-layout='single-line'])
has([data-xh-field-input][data-xh-field-layout='textarea'])
xh-field-chrome
xh-field-input
xh-field-layout=multi-tag
xh-field-layout=single-line
xh-field-layout=textarea
--xh-_combobox-hcombobox 的 control 部件 block-size、min-block-size 覆盖槽。
--xh-combobox-control-min-wcontrol
root
min-inline-sizedefault
xh-field-chrome
--xh-control-min-wcombobox 的 control、root 部件 min-inline-size 覆盖槽。
--xh-combobox-control-pxcontrolpadding-inlinexh-field-chrome--xh-_combobox-pxcombobox 的 control 部件 padding-inline 覆盖槽。
--xh-combobox-control-radiuscontrolborder-radiusxh-field-chrome--xh-shape-controlcombobox 的 control 部件 border-radius 覆盖槽。
--xh-combobox-control-shadowcontrolbox-shadowxh-field-chromenonecombobox 的 control 部件 box-shadow 覆盖槽。
--xh-combobox-control-wrootinline-size
min-inline-size
default--xh-control-wcombobox 的 root 部件 inline-size、min-inline-size 覆盖槽。
--xh-combobox-empty-fgemptycolordefault--xh-material-frosted-fg-mutedcombobox 的 empty 部件 color 覆盖槽。
--xh-combobox-empty-font-sizeemptyfont-sizedefault--xh-_combobox-font-sizecombobox 的 empty 部件 font-size 覆盖槽。
--xh-combobox-empty-pxemptypadding-inlinedefault--xh-control-px-mdcombobox 的 empty 部件 padding-inline 覆盖槽。
--xh-combobox-empty-pyemptypadding-blockdefault--xh-space-3combobox 的 empty 部件 padding-block 覆盖槽。
--xh-combobox-gaprootgapdefault--xh-space-1combobox 的 root 部件 gap 覆盖槽。
--xh-combobox-group-gapgroupgapdefault--xh-list-option-gapcombobox 的 group 部件 gap 覆盖槽。
--xh-combobox-group-label-fggroup-labelcolordefault--xh-material-frosted-fg-mutedcombobox 的 group-label 部件 color 覆盖槽。
--xh-combobox-group-label-font-sizegroup-labelfont-sizedefault--xh-text-caption-sizecombobox 的 group-label 部件 font-size 覆盖槽。
--xh-combobox-group-label-font-weightgroup-labelfont-weightdefault--xh-font-weight-mediumcombobox 的 group-label 部件 font-weight 覆盖槽。
--xh-combobox-group-label-pxgroup-labelpadding-inlinedefault--xh-control-px-mdcombobox 的 group-label 部件 padding-inline 覆盖槽。
--xh-combobox-group-label-pygroup-labelpadding-blockdefault--xh-space-1combobox 的 group-label 部件 padding-block 覆盖槽。
--xh-combobox-group-spacinggroupmargin-block-startdefault--xh-space-1_5combobox 的 group 部件 margin-block-start 覆盖槽。
--xh-combobox-icon-sizecontrol
positioner
root
--xh-icon-sizeis([data-part='root'], [data-part='positioner'])
size=lg
size=sm
xh-field-chrome
--xh-_field-size-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
combobox 的 control、positioner、root 部件 --xh-icon-size 覆盖槽。
--xh-combobox-input-autofill-bginputbox-shadow-webkit-autofill
autofill
xh-field-input
--xh-bg-canvascombobox 的 input 部件 box-shadow 覆盖槽。
--xh-combobox-input-autofill-fginput-webkit-text-fill-color-webkit-autofill
autofill
xh-field-input
--xh-fg-defaultcombobox 的 input 部件 -webkit-text-fill-color 覆盖槽。
--xh-combobox-input-fginputcolorxh-field-input--xh-combobox-control-fgcombobox 的 input 部件 color 覆盖槽。
--xh-combobox-input-font-sizeinputfont-sizexh-field-input--xh-_combobox-font-sizecombobox 的 input 部件 font-size 覆盖槽。
--xh-combobox-item-bg-hoveritembackground-colordisabled
error
highlighted
hover
is(:focus-visible, [data-highlighted])
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
selected
xh-collection-context=overlay
--xh-bg-subtlecombobox 的 item 部件 background-color 覆盖槽。
--xh-combobox-item-bg-presseditembackground-colordisabled
error
is(:active, [data-pressed])
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
selected
xh-collection-context=overlay
--xh-bg-subtle-hovercombobox 的 item 部件 background-color 覆盖槽。
--xh-combobox-item-check-fgitemcolordisabled
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
state=checked
xh-collection-context=overlay
xh-collection-slot=indicator
--xh-combobox-item-indicator-fgcombobox 的 item 部件 color 覆盖槽。
--xh-combobox-item-fgitemcolordefault
disabled
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=overlay
--xh-material-frosted-fgcombobox 的 item 部件 color 覆盖槽。
--xh-combobox-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=overlay
--xh-combobox-item-fgcombobox 的 item 部件 color 覆盖槽。
--xh-combobox-item-font-sizeitemfont-sizedefault--xh-_combobox-font-sizecombobox 的 item 部件 font-size 覆盖槽。
--xh-combobox-item-font-weight-selecteditemfont-weightdisabled
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=overlay
--xh-font-weight-regularcombobox 的 item 部件 font-weight 覆盖槽。
--xh-combobox-item-gapitemmargin-inline-end
margin-inline-start
xh-collection-slot=indicator
xh-collection-slot=prefix
xh-collection-slot=shortcut
xh-collection-slot=suffix
--xh-_combobox-gapcombobox 的 item 部件 margin-inline-end、margin-inline-start 覆盖槽。
--xh-combobox-item-indicator-fgitemcolordisabled
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
state=checked
xh-collection-context=overlay
xh-collection-slot=indicator
--xh-_combobox-accentcombobox 的 item 部件 color 覆盖槽。
--xh-combobox-item-indicator-sizeitem-indicator--xh-icon-size
block-size
inline-size
default--xh-control-indicator-sizecombobox 的 item-indicator 部件 --xh-icon-size、block-size、inline-size 覆盖槽。
--xh-combobox-item-leadingitemline-heightdefault--xh-leading-normalcombobox 的 item 部件 line-height 覆盖槽。
--xh-combobox-item-pxitempadding-inlinedefault--xh-_combobox-item-pxcombobox 的 item 部件 padding-inline 覆盖槽。
--xh-combobox-item-pyitempadding-blockdefault--xh-_combobox-item-pycombobox 的 item 部件 padding-block 覆盖槽。
--xh-combobox-item-radiusitemborder-radiusdefault--xh-shape-controlcombobox 的 item 部件 border-radius 覆盖槽。
--xh-combobox-label-fglabelcolordefault--xh-fg-defaultcombobox 的 label 部件 color 覆盖槽。
--xh-combobox-label-fg-disabledlabelcolordisabled--xh-fg-subtlecombobox 的 label 部件 color 覆盖槽。
--xh-combobox-label-font-sizelabelfont-sizedefault--xh-text-label-sizecombobox 的 label 部件 font-size 覆盖槽。
--xh-combobox-label-font-weightlabelfont-weightdefault--xh-text-label-weightcombobox 的 label 部件 font-weight 覆盖槽。
--xh-combobox-layerpositionerz-indexdefault--xh-_layercombobox 的 positioner 部件 z-index 覆盖槽。
--xh-combobox-loading-fgloadingcolordefault--xh-material-frosted-fg-mutedcombobox 的 loading 部件 color 覆盖槽。
--xh-combobox-loading-font-sizeloadingfont-sizedefault--xh-_combobox-font-sizecombobox 的 loading 部件 font-size 覆盖槽。
--xh-combobox-loading-pxloadingpadding-inlinedefault--xh-control-px-mdcombobox 的 loading 部件 padding-inline 覆盖槽。
--xh-combobox-loading-pyloadingpadding-blockdefault--xh-space-3combobox 的 loading 部件 padding-block 覆盖槽。
--xh-combobox-placeholder-fginputcolorplaceholder
xh-field-input
--xh-fg-subtlecombobox 的 input 部件 color 覆盖槽。

动效 ​

动效角色:按压 · 状态 · 切换 · 出现(锚定列表)(见动效规范)。

共享关键帧 xh-overlay-slide-in · xh-overlay-slide-out 由 family/motion.css 提供,皮肤 @import 它,单独引入仍成立;rotate 走 transition 过渡。时长与缓动读动效令牌,改令牌即改全局节奏。

皮肤之外还有一段:退场由适配器的退场闸门把关,动画播完才真收起。

系统开启减弱动效时由令牌层统一收敛,皮肤不另作判断。

RTL ​

皮肤用逻辑属性排布(inline-start 一族),dir="rtl" 下自动镜像。

Released under The MIT License