跳转到内容

Select 选择器 ​

从已知清单中选择一个或多个值,选项收在浮层内。

用法 ​

单选

水果

组件结构 ​

加粗的是必需部件。

data-scope="select":root · label · control · trigger · value-text · indicator · clear-trigger · tag-list · positioner · content · list · footer · group · group-label · item · item-prefix · item-text · item-description · item-suffix · item-indicator · empty · loading · hidden-select

示例 ​

多选 ​

选择多个值

水果(多选)

已选:apple

受控 ​

由 value 和 value-change 控制

水果

宿主持有的值:banana

禁用 ​

禁止展开和聚焦

水果

变体 ​

outline、subtle 和 ghost

outline
subtle
ghost

颜色 ​

六种语气

brand
neutral
success
warning
danger
info

尺寸 ​

小、中、大三档

小
默认
大

异步加载 ​

展开时加载选项

曲目

当前值:(未选)

宽度 ​

分别设置控件和浮层宽度

缺省宽度
加宽

自定义内容 ​

自定义选项和当前值

负责人

操作入口 ​

通过插槽状态控制开合和值

水果

大量选项 ​

列表内部滚动并支持连打检索

仓位

分组 ​

跨分组保持键盘导航

食材

当前值:(未选)

多选标签 ​

超出数量合并为 +N

技术栈
Vue Svelte Solid

校验 ​

显示无效状态和错误说明

所属部门

这一项必填

滚动加载 ​

到达列表底部加载下一页

工单

已加载 20 / 80 条

命令式聚焦 ​

聚焦触发器

优先级

清空 ​

有值时显示清空按钮

所属小组

底部操作区 ​

固定在滚动列表下方

水果

当前值:(未选)

Popover + Listbox ​

不参与表单的选择

选项副文本 ​

一行放不下的解释写在第 2 行

订阅方案

行首与行尾 ​

两格交给作者,文字与副文本仍由数据铺

状态

设计指引 ​

何时使用 ​

  • 从已知选项中选择一个或多个值。
  • 需要分组、标签多选或异步加载。

何时不用 ​

特性 ​

  • 通过 hidden-select 参与表单。
  • 多选值可显示为标签,超出 maxTagCount 后合并为 +N。
  • 支持分组、加载、空状态、底部操作区和滚动加载。
  • 选项可逐条声明语气,失效或需要留意的那条自带该族字色与高亮底。
  • 选项可写副文本,第 2 行放一句解释,与标题同列、走 muted 档。
  • 行首与行尾两格各有逐条钩子:只想加个图标或计数,不必把整条重搭。
  • 控件使用 Field Chrome,浮层使用 M2 磨砂表面。
  • 选中项保留普通文字,通过末端对号表示状态。
  • 关闭时立即退出交互,资源在退场动画结束后释放。

组合 ​

最佳实践 ​

  • 固定触发器宽度,避免选中值改变布局。
  • 选项较多或需要搜索时使用 Combobox。
  • 自定义内容中的主要文字放在 item-text 中。

反模式 ​

  • 不要用 Select 承载“导出”“删除”等动作。
  • 异步加载时不要省略加载和空状态。

API 参考 ​

产物 ​

层值
自定义元素<xh-select>
Vue 组件XhSelectClearTrigger XhSelectContent XhSelectControl XhSelectEmpty XhSelectFooter XhSelectGroup XhSelectGroupLabel XhSelectIndicator XhSelectItem XhSelectItemDeleteTrigger XhSelectItemDescription XhSelectItemIndicator XhSelectItemPrefix XhSelectItemSuffix XhSelectItemText XhSelectLabel XhSelectList XhSelectLoading XhSelectOverflowTag XhSelectPositioner XhSelectRoot XhSelectTag XhSelectTagLabel XhSelectTagList XhSelectTrigger XhSelectValueText
组合式函数useSelect
状态机selectMachine
皮肤@xihan-ui/styles/select.css

Props ​

属性类型必填说明
collectionSelectNode[]条目数据,显示文本与禁用的事实源。提供后条目部件只需声明 value, 显示文本也不再从 DOM 查询。未提供时回到文本写在条目中、从 DOM 查询的方式。
valuestring | string[] | null选中值。裸串是单选的简写,null 是受控且无选中,未提供(undefined)才是非受控;内部一律按数组处理。 受控时 cell 直读 prop,写入只发 onValueChange 不落内部值。
defaultValuestring | string[] | null非受控初始选中值。与 value 同样接受裸串与 null。
multipleboolean允许选中多项。单选时选完即收起,多选时保持展开继续选。
openboolean展开态。提供即受控:内部不再自行修改,只发 onOpenChange。
defaultOpenboolean
disabledboolean整个控件禁用:trigger 使用原生 disabled,隐藏 select 不参与提交。
readOnlyboolean只读:浮层照常展开与浏览,但选中值不可修改、也不可清空。
invalidboolean校验错误态:trigger 标红并输出 aria-invalid。
loadingboolean条目加载中:列表报告 aria-busy,显示在途占位、隐藏空态占位。
translationsPartial<SelectTranslations>读屏文案,默认英文。
maxTagCountnumber多选标签最多显示的数量,其余折叠进 overflowCount、合成 +N 标签;默认 3(SELECT_DEFAULT_MAX_TAG_COUNT)。
requiredboolean原生表单校验:无选中值时提交被拦截。
namestring表单字段名。提供后隐藏 select 才带 name,选中值随表单一并提交。
placeholderstring无选中时 value-text 显示的占位文字。
placementPlacement
offsetnumber
loopboolean方向键到达末尾是否回绕,默认 true。
dirDirection文字方向,默认 ltr。
variantControlVariant形态:outline / subtle / ghost,决定触发器的描边与底色使用方式。默认 outline。
toneTone语气:brand / neutral / success / warning / danger / info,决定聚焦与选中强调使用哪族颜色。
sizeSize尺寸:sm / md / lg,决定触发器高度、内边距与字号档位。
onValueChange(details: SelectValueChangeDetails) => voidvalue 变化意图回调;受控时是唯一出口,非受控时随内部写入一并通知。
onOpenChange(details: SelectOpenChangeDetails) => voidopen 变化意图回调;受控时是唯一出口,非受控时随内部转移一并通知。

SelectNode ​

collection 的元素。

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

事件 ​

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

事件载荷说明
value-changeSelectValueChangeDetails选中值变化;detail 为 { value: string[] }
open-changeSelectOpenChangeDetailsopen 状态变化;detail 为 { open: boolean }

插槽 ​

仅列出带载荷的插槽。

Vue 组件插槽载荷说明
XhSelectRootdefaultSelectRootSlotProps
XhSelectRootlabel—
XhSelectRootitemSelectNodeMeta只填条目的文字槽,副文本与首尾两格照旧各归各的
XhSelectRootitem-prefixSelectNodeMeta只接管行首那一格,其余槽照旧由数据铺
XhSelectRootitem-suffixSelectNodeMeta只接管行尾那一格(计数、徽标、次级图标),其余槽照旧由数据铺

React 适配器 props ​

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

React 组件属性类型必填说明
XhSelectGroupvaluestring是
XhSelectItemvaluestring是
XhSelectItemdisabledboolean默认交给 connect 查询 collection,写死 false 会覆盖数据中的禁用。
XhSelectPositionercontainer() => Element | null浮层挂载的容器;未提供时按全局配置,再未提供时挂载到 body。
XhSelectRootlabelReactNode标题文字。提供后不必再写 label 部件。
XhSelectRootclearableboolean自动渲染树中是否带清空按钮;手写部件不使用它,写了节点即可清空。
XhSelectRootrenderItem(node: SelectNodeMeta) => ReactNode每个条目的自定义内容;未提供时使用 collection 中的 label。
XhSelectRootrenderItemPrefix(node: SelectNodeMeta) => ReactNode只接管条目行首那一格;其余槽仍由数据铺。
XhSelectRootrenderItemSuffix(node: SelectNodeMeta) => ReactNode只接管条目行尾那一格;其余槽仍由数据铺。
XhSelectRootchildrenSlotChildren<SelectRootSlotProps>
XhSelectTagvaluestring是它代表哪个选中值。

状态 ​

公开状态写入 data-state。

部件取值
root'open' | 'closed'
control'open' | 'closed'
trigger'open' | 'closed'
indicator'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'
list'open' | 'closed'
footer'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 · ITEM.HIGHLIGHT · HIGHLIGHT.CLEAR · ITEM.LOST · ITEM.SELECT · VALUE.SET · VALUE.CLEAR · FORM.RESET · PRESS.START · PRESS.END

判据:isOpenControlled · isMultiple · isReadOnly · canPress

connect API ​

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

成员类型说明
openboolean
collectionreadonly SelectNodeMeta[]由 collection 推导的条目元信息,按数据顺序排列;未提供 collection 时为空数组。
valuestring[]选中集合,按选中先后排列而非文档顺序。单选恒为长度 ≤ 1。
valueTextstring[]选中项的文本,与 value 逐项等长对应;某项在 DOM 中查询不到条目时该项回退为值本身。
displayTextstringvalue-text 实际显示的文字:有选中时取其文本(多选按半角逗号加空格连接),否则取 placeholder。
multipleboolean是否允许多选。
invalidboolean校验错误态。
readOnlyboolean只读态。
canClearboolean当前能否清空:有选中且既不禁用也不只读。
tagsSelectTagMeta[]可见标签(受 maxTagCount 截断),与 value / valueText 同序。
overflowCountnumber被 maxTagCount 折叠的标签数。
overflowTextstring+N 标签显示的文字(由 translations.overflowTag 计算);没有折叠的标签时为空串。
highlightedValuestring | null高亮锚点;收起时为 null。
setOpen(next: boolean) => void
setValue(next: string | string[]) => void
clear() => void清空全部选中。
deselect(value: string) => void移除一个选中值。
getRootProps() => T['element']
getLabelProps() => T['element']
getControlProps() => T['element']触发器与清空按钮的收纳容器:两者在其中并排,有值时清空按钮替代展开指示符。
getTriggerProps() => T['button']
getValueTextProps() => T['element']
getIndicatorProps() => T['element']
getClearTriggerProps() => T['button']清空按钮:不占 Tab 位;无法清空时整体隐藏;点击清空全部选中、不展开浮层,焦点送回 trigger。
getTagListProps() => T['element']标签行:收纳可见标签与 +N 标签,放在触发器中;无选中时整体 hidden。
getTagProps(props: SelectTagProps) => T['element']标签:一个选中值一个,即库内 tag 的 root(data-scope="tag"):语气、尺寸与禁用从本控件传下,形态按控件的面派生(outline / ghost / 默认使用淡底标签,subtle 使用描边标签),另带 data-value 记录代表的值。放在触发器中即纯展示(不渲染关闭按钮),放在外部配删除按钮可删除。
getTagLabelProps() => T['element']标签文字所在的块(tag 的 label):截断落在这一层;标签与 +N 共用。
getOverflowTagProps() => T['element']被折叠的标签合成的一个:同样是 tag 的 root,显示 overflowText、带 data-count;没有折叠的标签时 hidden。
getItemDeleteTriggerProps(props: SelectTagProps) => T['button']标签删除按钮:即所在标签那份 tag 的 close-trigger(data-scope="tag"),可及名使用 translations.deleteItem,禁用时保留位置、原生 disabled;点击移除所在标签的选中值;须放在标签中。
getPositionerProps() => T['element']
getContentProps() => T['element']浮层外壳:描边、底色、阴影与键盘收口都在它身上。
getListProps() => T['element']列表框本体,滚动在这一层;role=listbox 与条目的拥有关系都归它。
getFooterProps() => T['element']浮层底部的操作区,是 list 的兄弟;不在列表框的拥有关系中,也不参与方向键与连打检索。
getEmptyProps() => T['element']空态占位:放在 content 中、list 的兄弟。 提供 collection 时由连接层按条数收放;条目手写时不写 hidden,是否显示由作者决定。
getLoadingProps() => T['element']在途占位:与空态占位同一位置,两者不同时显示:加载期间显示它,空态让位。 提供 collection 时由连接层按条数收放;条目手写时只按 loading 收放。
getGroupProps(props: SelectGroupProps) => T['element']分组容器:role=group,条目挂在其中;分组标题经 aria-labelledby 关联。
getGroupLabelProps(props: SelectGroupProps) => T['element']分组标题:不是选项、不进入导航,只作为本组的可及名。
getItemProps(props: SelectItemProps) => T['element']
getItemPrefixProps(props: SelectItemProps) => T['element']
getItemTextProps(props: SelectItemProps) => T['element']
getItemDescriptionProps(props: SelectItemProps) => T['element']
getItemSuffixProps(props: SelectItemProps) => T['element']
getItemIndicatorProps(props: SelectItemProps) => T['element']
getHiddenSelectProps() => T['select']表单出口:一份视觉隐藏的原生 select,由根部件自行渲染(作者不必手写)。 选项由适配器按当前值补齐,原生提交与 required 校验据此获取值。

无障碍 ​

键盘 ​

规格出处:W3C APG

按键生效条件行为
Enter / Spaceclosed, focus in trigger展开列表并把高亮落到当前选中项(无选中则落首个可用条目)
ArrowDownclosed, focus in trigger展开列表并把高亮落到选中项的下一个可用条目
ArrowUpclosed, focus in trigger展开列表并把高亮落到选中项的上一个可用条目
单个可打印字符closed, focus in trigger连打检索命中的条目直接成为选中值(多选是加进集合,已在集合里则不动),列表不展开
Deleteclosed, focus in trigger, 有选中值且未禁用、未只读清空全部选中,列表不展开
Backspaceclosed, focus in trigger, 有选中值且未禁用、未只读单选清空;多选去掉最后一个选中值,列表不展开
ArrowDownopen, focus in content高亮移到下一个条目(禁用项跳过、尽头按 loop 回绕)
ArrowUpopen, focus in content高亮移到上一个条目(禁用项跳过、尽头按 loop 回绕)
Homeopen, focus in content高亮移到首个可用条目
Endopen, focus in content高亮移到末个可用条目
单个可打印字符open, focus in content连打检索移动高亮,不改选中值
Enter / Spaceopen, 单选, 高亮条目未禁用选中高亮条目并关闭列表,焦点归还 trigger
Enter / Spaceheld in item / clear-trigger, 未禁用、未只读按住期间该部件投影 data-pressed,与指针 :active 同一副按压面;抬起或失焦撤下,条目随浮层收起一并撤下;没有值可清时清空按钮不进
Enter / Spaceopen, 多选, 高亮条目未禁用切换高亮条目的选中态,列表不收起、焦点留在条目上
Escapeopen关闭列表并把焦点归还 trigger,选中值不变
Tab / Shift+Tabopen关闭列表,焦点不归还 trigger,按 Tab 序列自然离开

ARIA ​

以下属性由 connect 生成。

部件属性值
triggeraria-controlscontent 部件的 id
triggeraria-expanded'true' | 'false'
triggeraria-haspopup'listbox'
triggeraria-invalid'true' | 'false'
triggeraria-labelledbylabel 部件的 id value-text 部件的 id
triggeraria-readonly'true' | 'false'
triggerrole'combobox'
indicatoraria-hidden'true'
clear-triggeraria-labelprops.translations.clearTrigger
contentaria-hidden!open || undefined
listaria-busy'true' | undefined
listaria-labelprops.translations.content
listaria-labelledbylabel 部件的 id value-text 部件的 id
listaria-multiselectable'true' | 'false'
listrole'listbox'
grouparia-labelledbygroup-label 部件的 id
grouprole'group'
itemaria-disabled'true' | 'false'
itemaria-selected'true' | 'false'
itemrole'option'
item-prefixaria-hidden'true'
item-indicatoraria-hidden'true'
hidden-selectaria-hidden'true'

样式参考 ​

皮肤 ​

@xihan-ui/styles/select.css 使用 [data-scope="select"][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
triggerdata-disabled''(条件成立时才出现)
triggerdata-invalid''(条件成立时才出现)
triggerdata-placeholder''(条件成立时才出现)
triggerdata-readonly''(条件成立时才出现)
triggerdata-state'open' | 'closed'
value-textdata-disabled''(条件成立时才出现)
value-textdata-placeholder''(条件成立时才出现)
indicatordata-clearable''(条件成立时才出现)
indicatordata-disabled''(条件成立时才出现)
indicatordata-state'open' | 'closed'
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'
tag-listdata-disabled''(条件成立时才出现)
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'
listdata-state'open' | 'closed'
footerdata-state'open' | 'closed'
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-state'checked' | 'unchecked'
item-prefixdata-xh-collection-slot'prefix'
item-textdata-disabled''(条件成立时才出现)
item-textdata-state'checked' | 'unchecked'
item-textdata-xh-collection-slot'text'
item-descriptiondata-disabled''(条件成立时才出现)
item-descriptiondata-state'checked' | 'unchecked'
item-descriptiondata-xh-collection-slot'description'
item-suffixdata-disabled''(条件成立时才出现)
item-suffixdata-state'checked' | 'unchecked'
item-suffixdata-xh-collection-slot'suffix'
item-indicatordata-disabled''(条件成立时才出现)
item-indicatordata-state'checked' | 'unchecked'
item-indicatordata-xh-collection-slot'indicator'
emptydata-state'open' | 'closed'
loadingdata-state'open' | 'closed'
overflow-tagdata-countString(overflowCount)
tagdata-valuev

CSS 变量 ​

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

变量部件CSS 属性状态默认来源说明
--xh-select-action-bgclear-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-restselect 的 clear-trigger 部件 --xh-ink-surface、background-color 覆盖槽。
--xh-select-action-bg-activeclear-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressedselect 的 clear-trigger 部件 background-color 覆盖槽。
--xh-select-action-bg-hoverclear-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hoverselect 的 clear-trigger 部件 background-color 覆盖槽。
--xh-select-action-fgclear-triggercolordefault--xh-fg-mutedselect 的 clear-trigger 部件 color 覆盖槽。
--xh-select-action-fg-hoverclear-triggercolordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-fg-defaultselect 的 clear-trigger 部件 color 覆盖槽。
--xh-select-action-font-sizeclear-triggerfont-sizedefault--xh-text-secondary-sizeselect 的 clear-trigger 部件 font-size 覆盖槽。
--xh-select-action-radiusclear-triggerborder-radiusdefault--xh-shape-insetselect 的 clear-trigger 部件 border-radius 覆盖槽。
--xh-select-action-sizeclear-trigger
indicator
block-size
inline-size
min-inline-size
default
xh-action-profile=field-inset
--xh-_action-profile-visual-size
--xh-control-action-size
select 的 clear-trigger、indicator 部件 block-size、inline-size、min-inline-size 覆盖槽。
--xh-select-content-backdropcontent-webkit-backdrop-filter
backdrop-filter
xh-material=frosted--xh-_material-backdropselect 的 content 部件 -webkit-backdrop-filter、backdrop-filter 覆盖槽。
--xh-select-content-bgcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-bgselect 的 content 部件 background 覆盖槽。
--xh-select-content-bordercontentbordernot([data-xh-action-control])
xh-material=frosted
--xh-_material-borderselect 的 content 部件 border 覆盖槽。
--xh-select-content-fgcontentcolornot([data-xh-action-control])
xh-material=frosted
--xh-_material-fgselect 的 content 部件 color 覆盖槽。
--xh-select-content-highlightcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-highlightselect 的 content 部件 background 覆盖槽。
--xh-select-content-max-hcontentmax-block-sizedefault--xh-overlay-menu-max-hselect 的 content 部件 max-block-size 覆盖槽。
--xh-select-content-max-wcontentmax-inline-sizedefault--xh-overlay-max-wselect 的 content 部件 max-inline-size 覆盖槽。
--xh-select-content-min-wcontentmin-inline-sizedefault--xh-overlay-menu-min-wselect 的 content 部件 min-inline-size 覆盖槽。
--xh-select-content-pxcontentpadding-inlinedefault--xh-space-1select 的 content 部件 padding-inline 覆盖槽。
--xh-select-content-pycontentpadding-blockdefault--xh-space-1select 的 content 部件 padding-block 覆盖槽。
--xh-select-content-radiuscontentborder-radiusdefault--xh-shape-overlayselect 的 content 部件 border-radius 覆盖槽。
--xh-select-content-shadowcontentbox-shadownot([data-xh-action-control])
xh-material=frosted
--xh-_material-shadowselect 的 content 部件 box-shadow 覆盖槽。
--xh-select-control-bgcontrolbackground-colorxh-field-chrome--xh-_field-variant-bg-restselect 的 control 部件 background-color 覆盖槽。
--xh-select-control-bg-disabledcontrolbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabledselect 的 control 部件 background-color 覆盖槽。
--xh-select-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-hoverselect 的 control 部件 background-color 覆盖槽。
--xh-select-control-bg-readonlycontrolbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-onlyselect 的 control 部件 background-color 覆盖槽。
--xh-select-control-bordercontrolborderxh-field-chrome--xh-_field-variant-border-restselect 的 control 部件 border 覆盖槽。
--xh-select-control-border-focuscontrolborder-colordisabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focusselect 的 control 部件 border-color 覆盖槽。
--xh-select-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-hoverselect 的 control 部件 border-color 覆盖槽。
--xh-select-control-border-invalidcontrolborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalidselect 的 control 部件 border-color 覆盖槽。
--xh-select-control-fgcontrolcolorxh-field-chrome--xh-fg-defaultselect 的 control 部件 color 覆盖槽。
--xh-select-control-gapcontrolgapxh-field-chrome--xh-_select-gapselect 的 control 部件 gap 覆盖槽。
--xh-select-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-_select-hselect 的 control 部件 block-size、min-block-size 覆盖槽。
--xh-select-control-min-wcontrol
root
min-inline-sizedefault
xh-field-chrome
--xh-control-min-wselect 的 control、root 部件 min-inline-size 覆盖槽。
--xh-select-control-pxcontrolpadding-inlinexh-field-chrome--xh-_select-pxselect 的 control 部件 padding-inline 覆盖槽。
--xh-select-control-radiuscontrolborder-radiusxh-field-chrome--xh-shape-controlselect 的 control 部件 border-radius 覆盖槽。
--xh-select-control-shadowcontrolbox-shadowxh-field-chromenoneselect 的 control 部件 box-shadow 覆盖槽。
--xh-select-control-wrootinline-size
min-inline-size
default--xh-control-wselect 的 root 部件 inline-size、min-inline-size 覆盖槽。
--xh-select-empty-fgemptycolordefault--xh-material-frosted-fg-mutedselect 的 empty 部件 color 覆盖槽。
--xh-select-empty-font-sizeemptyfont-sizedefault--xh-_select-font-sizeselect 的 empty 部件 font-size 覆盖槽。
--xh-select-empty-pxemptypadding-inlinedefault--xh-_select-item-pxselect 的 empty 部件 padding-inline 覆盖槽。
--xh-select-empty-pyemptypadding-blockdefault--xh-space-3select 的 empty 部件 padding-block 覆盖槽。
--xh-select-footer-borderfooterborder-block-startdefault--xh-material-frosted-separatorselect 的 footer 部件 border-block-start 覆盖槽。
--xh-select-footer-fgfootercolordefault--xh-material-frosted-fg-mutedselect 的 footer 部件 color 覆盖槽。
--xh-select-footer-font-sizefooterfont-sizedefault--xh-text-secondary-sizeselect 的 footer 部件 font-size 覆盖槽。
--xh-select-footer-gapfootergapdefault--xh-space-2select 的 footer 部件 gap 覆盖槽。
--xh-select-footer-pxfooterpadding-inlinedefault--xh-space-2select 的 footer 部件 padding-inline 覆盖槽。
--xh-select-footer-pyfooterpadding-blockdefault--xh-space-2select 的 footer 部件 padding-block 覆盖槽。
--xh-select-gaprootgapdefault--xh-space-1select 的 root 部件 gap 覆盖槽。
--xh-select-group-gapgroupgapdefault--xh-list-option-gapselect 的 group 部件 gap 覆盖槽。
--xh-select-group-label-fggroup-labelcolordefault--xh-material-frosted-fg-mutedselect 的 group-label 部件 color 覆盖槽。
--xh-select-group-label-font-sizegroup-labelfont-sizedefault--xh-text-caption-sizeselect 的 group-label 部件 font-size 覆盖槽。
--xh-select-group-label-font-weightgroup-labelfont-weightdefault--xh-font-weight-mediumselect 的 group-label 部件 font-weight 覆盖槽。
--xh-select-group-label-pxgroup-labelpadding-inlinedefault--xh-_select-item-pxselect 的 group-label 部件 padding-inline 覆盖槽。
--xh-select-group-label-pygroup-labelpadding-blockdefault--xh-space-1select 的 group-label 部件 padding-block 覆盖槽。
--xh-select-group-separator-colorgroupborder-block-startdefault--xh-material-frosted-separatorselect 的 group 部件 border-block-start 覆盖槽。
--xh-select-group-spacinggrouppadding-block-startdefault--xh-space-1_5select 的 group 部件 padding-block-start 覆盖槽。
--xh-select-icon-sizecontrol
root
--xh-icon-sizedefault
size=lg
size=sm
xh-field-chrome
--xh-_field-size-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
select 的 control、root 部件 --xh-icon-size 覆盖槽。
--xh-select-indicator-fgindicatorcolordefault--xh-fg-mutedselect 的 indicator 部件 color 覆盖槽。
--xh-select-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-subtleselect 的 item 部件 background-color 覆盖槽。
--xh-select-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-hoverselect 的 item 部件 background-color 覆盖槽。
--xh-select-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-_select-accentselect 的 item 部件 color 覆盖槽。
--xh-select-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-fgselect 的 item 部件 color 覆盖槽。
--xh-select-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-select-item-fgselect 的 item 部件 color 覆盖槽。
--xh-select-item-font-sizeitemfont-sizedefault--xh-_select-font-sizeselect 的 item 部件 font-size 覆盖槽。
--xh-select-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-regularselect 的 item 部件 font-weight 覆盖槽。
--xh-select-item-gapitemmargin-inline-end
margin-inline-start
xh-collection-slot=indicator
xh-collection-slot=prefix
xh-collection-slot=shortcut
xh-collection-slot=suffix
--xh-_select-gapselect 的 item 部件 margin-inline-end、margin-inline-start 覆盖槽。
--xh-select-item-indicator-sizeitem-indicator--xh-icon-size
block-size
inline-size
default--xh-control-indicator-sizeselect 的 item-indicator 部件 --xh-icon-size、block-size、inline-size 覆盖槽。
--xh-select-item-leadingitemline-heightdefault--xh-leading-normalselect 的 item 部件 line-height 覆盖槽。
--xh-select-item-pxitempadding-inlinedefault--xh-_select-item-pxselect 的 item 部件 padding-inline 覆盖槽。
--xh-select-item-pyitempadding-blockdefault--xh-_select-item-pyselect 的 item 部件 padding-block 覆盖槽。
--xh-select-item-radiusitemborder-radiusdefault--xh-shape-controlselect 的 item 部件 border-radius 覆盖槽。
--xh-select-label-fglabelcolordefault--xh-fg-defaultselect 的 label 部件 color 覆盖槽。
--xh-select-label-fg-disabledlabelcolordisabled--xh-fg-subtleselect 的 label 部件 color 覆盖槽。
--xh-select-label-font-sizelabelfont-sizedefault--xh-text-label-sizeselect 的 label 部件 font-size 覆盖槽。
--xh-select-label-font-weightlabelfont-weightdefault--xh-text-label-weightselect 的 label 部件 font-weight 覆盖槽。
--xh-select-layerpositionerz-indexdefault--xh-_layerselect 的 positioner 部件 z-index 覆盖槽。
--xh-select-list-gaplistgapdefault--xh-list-option-gapselect 的 list 部件 gap 覆盖槽。
--xh-select-loading-fgloadingcolordefault--xh-material-frosted-fg-mutedselect 的 loading 部件 color 覆盖槽。
--xh-select-loading-font-sizeloadingfont-sizedefault--xh-_select-font-sizeselect 的 loading 部件 font-size 覆盖槽。
--xh-select-loading-pxloadingpadding-inlinedefault--xh-_select-item-pxselect 的 loading 部件 padding-inline 覆盖槽。
--xh-select-loading-pyloadingpadding-blockdefault--xh-space-3select 的 loading 部件 padding-block 覆盖槽。
--xh-select-placeholder-fgvalue-textcolorplaceholder--xh-fg-subtleselect 的 value-text 部件 color 覆盖槽。
--xh-select-tag-list-gaptag-listgapdefault--xh-space-1select 的 tag-list 部件 gap 覆盖槽。
--xh-select-trigger-fgtriggercolordefault--xh-fg-defaultselect 的 trigger 部件 color 覆盖槽。
--xh-select-trigger-font-sizetriggerfont-sizedefault--xh-_select-font-sizeselect 的 trigger 部件 font-size 覆盖槽。
--xh-select-trigger-gaptriggergapdefault--xh-_select-gapselect 的 trigger 部件 gap 覆盖槽。

动效 ​

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

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

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

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

RTL ​

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

Released under The MIT License