跳转到内容

TimePicker 时间选择器 ​

将可键入的分段时间框、时钟触发器和分列选择浮层组合成一个字段。

用法 ​

输入框与选择面板共享同一份值;按 15 分钟列出选项并实时显示结果

09:30
当前值:09:30

组件结构 ​

加粗的是必需部件。

data-scope="time-picker":root · label · control · segment-group · segment · trigger · clear-trigger · positioner · content · preset-group · preset · column · item · hidden-input

示例 ​

分列步长 ​

step=15 只裁剪浮层中的可选值(分列剩四格),段位上手动输入的分钟数不受它限制

09:30
当前值:09:30

12 小时制 ​

时列写的是显示值 01-12,落到哪个真实小时由上下午决定:输入行中输入、浮层中选择都会修改它

09:30上午
值仍是 24 小时的串:09:30

精度到秒 ​

granularity 同时决定输入行显示几段、浮层中排几列

--:--:--
当前值:(空)

禁用 / 只读 / 校验失败 ​

禁用整条退出 Tab 序列,只读仍能展开浏览只是不可修改值,invalid 只改变标注

09:30
09:30
09:30

可选时段 ​

min / max 直接把界外的格从列中裁掉;分列还会随已选的小时再裁剪一次

--:--
手打进段位的时间不受裁剪限制,越界只被标注:(空)

浮层中的操作按钮 ​

列表下方这排按钮是作者自己的节点,键盘事件在这一层收口,不再上交给列表

--:--
当前值:(空)

自定义可选格 ​

列中渲染哪几格由作者决定,午休两格整段移除;手动输入段位的小时被吸附到下一个可约小时

09:00
当前值:09:00

三轴 ​

variant 决定描边与底色的绘制方式、tone 决定使用哪族颜色、size 切换几何档;三者只落在 root,浮层中的格子一并随之变化

09:30
09:30
09:30
09:30
09:30
09:30
09:30
09:30
09:30

可选的触发按钮 ​

点击输入行本来就会展开,该按钮不是必需的;需要它是因为它才带 aria-haspopup / aria-expanded

09:30
当前值:09:30

快捷选项 ​

presets 在列旁边多排一列,点击一条即整份写入值并收起;时刻在组件外计算后再传入

--:--
当前值:(空)

设计指引 ​

何时使用 ​

  • 可选时间是离散的(每 15 分钟一档)。
  • 需要限制可选时段(营业时间、可预约时段)。

何时不用 ​

  • 任意时间都可以、用户直接键入时,使用时间字段。

特性 ​

  • step 分列设定各列的步长。
  • max 直接把界外的格从列中裁掉;分钟列还会随已选的小时再裁一次。
  • isTimeUnavailable 逐格判断可选性。
  • 浮层内可以放置“当前时刻”与确认按钮。
  • 触发器打开空值时焦点直接落到第一项;从输入段打开时继续保留键入焦点。
  • 快捷选项与时/分/秒列都从当前值恢复持久选中,并在逻辑末端显示对号。
  • 悬停、键盘高亮与可见焦点使用中性实体底,与选中对号可以同时存在。数字格在左右保留等宽标记轨,选中和 RTL 都不会把数字推离中心。
  • 输入框走 Field Chrome 描边式;浮层为 floating 实体面(border-default + floating 海拔);时分秒与快捷列各自接自绘条。
  • 浮层按实际弹出方向短距离淡入淡出,不缩放文字与数字;减弱动效和增强对比度沿用主题设置。
  • 空值时显示时钟入口;有值且渲染了清空按钮时,由清空按钮原位接替时钟图标。
  • 聚焦边界与当前段位使用短过渡,不以瞬时跳色表达焦点。

组合 ​

最佳实践 ​

  • 把不可选的时段裁掉而不是置灰,列更短、查找更快。
  • 打开时把浮层滚动到当前值。
  • 标准输入行应同时包含清空按钮与时钟图标触发器;二者按值互斥显示。参与表单时同时渲染隐藏输入。
  • 自定义格内文案保持简短;选中对号由皮肤统一绘制,不在插槽内重复添加。

反模式 ​

  • 步长设为 1 分钟:一列六十格,滚动过长。

API 参考 ​

产物 ​

层值
自定义元素<xh-time-picker>
Vue 组件XhTimePickerClearTrigger XhTimePickerColumn XhTimePickerContent XhTimePickerControl XhTimePickerHiddenInput XhTimePickerItem XhTimePickerLabel XhTimePickerPositioner XhTimePickerPreset XhTimePickerPresetGroup XhTimePickerRoot XhTimePickerSegment XhTimePickerSegmentGroup XhTimePickerTrigger
组合式函数useTimePicker
状态机timePickerMachine
皮肤@xihan-ui/styles/time-picker.css

Props ​

属性类型必填说明
valuestring受控值,ISO 时间串。提供即受控:cell 直读 prop,写入只发 onValueChange 不落内部值。
defaultValuestring
openboolean展开态。提供即受控:内部不再自行修改,只发 onOpenChange。
defaultOpenboolean
minstring下界(含)。裁掉浮层中落在界外的可选值,并把已填的越界值标注出来(不改写它)。
maxstring上界(含)。同上。
localestringBCP 47 语言标记。决定上午 / 下午的文字,以及未显式提供 hourCycle 时的小时制。
hourCycleTimeHourCycle小时制。未提供时按 locale 推断,locale 也没有时使用 24。
granularityTimeGranularity值精确到哪一段,默认 minute。它同时决定分段输入显示几段、浮层中排几列。
stepnumber分列的步进(分钟),默认 1。只影响浮层中的可选值,不限制手动输入的分钟数。
presetsTimePickerPreset[]快捷选项(「当前时刻」「上午 9 点」等)。提供后浮层中多出一列,点击即整份写入值并收起。 时刻需计算后传入:连接层每帧求值,把当前时刻放进渲染期会每帧得出一个新结果。 无法解析或落在 min / max 之外的选项自动不可按下;带秒的时刻按 granularity 归一后再比较与写入。
disabledboolean禁用:分段输入整组退出 Tab 序列、触发器使用原生 disabled,隐藏输入不参与提交。
readOnlyboolean只读:浮层照常展开、列表照常浏览,但值不可修改也不可清空。
invalidboolean校验失败标注。
requiredboolean必填标注(写入每段的 aria-required)。
namestring表单字段名;提供后隐藏输入才带 name,值随表单一并提交。
variantControlVariant形态:outline / subtle / ghost,决定输入行的描边与底色使用方式。默认 outline。
toneTone语气:brand / neutral / success / warning / danger / info,决定聚焦与选中强调使用哪族颜色。
sizeSize尺寸:sm / md / lg,输入行与浮层中的格子一并换档。
placementPlacement
dirDirection文字方向,默认 ltr。只改写浮层在行内轴上 start 与 end 的落点。
offsetnumber
isTimeUnavailable(value: string, unit: TimePickerColumnUnit) => boolean逐值可选性。接收两位补零的值与所属的列:同一个 '30' 在分钟列与秒列含义不同。 与 min / max 裁掉的值同等处理:判定为真的格子仍可聚焦,只是不可选中。 连续区间用 min / max 表达即可,该项留给每隔 15 分钟才可预约这类离散规则。
translationsPartial<TimePickerTranslations>段位读屏名的覆盖;未提供时使用内置英文语义名。
onValueChange(details: TimePickerValueChangeDetails) => void
onOpenChange(details: TimePickerOpenChangeDetails) => voidopen 变化意图回调;受控时是唯一出口,非受控时随内部转移一并通知。

TimePickerPreset ​

presets 的元素。

字段类型必填说明
valuestring是
labelstring是显示文案,同时是该项的可及名。
disabledboolean禁用该项:方向键仍可停留,但按下不写值。

事件 ​

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

事件载荷说明
value-changeTimePickerValueChangeDetails值变化;detail 为 { value: string }
open-changeTimePickerOpenChangeDetailsopen 状态变化;detail 为 { open: boolean }

插槽 ​

仅列出带载荷的插槽。

Vue 组件插槽载荷说明
XhTimePickerColumndefaultTimePickerColumnSlotProps
XhTimePickerPresetdefault—条目内容;未写时使用数据中的 label。
XhTimePickerPresetGroupdefaultTimePickerPresetsSlotProps自行铺设条目;未写时按 presets 数据自动铺设,两者产出的 DOM 一致。
XhTimePickerRootdefaultTimePickerRootSlotProps

React 适配器 props ​

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

React 组件属性类型必填说明
XhTimePickerColumnunitTimePickerColumnUnit是
XhTimePickerColumnchildrenSlotChildren<TimePickerColumnSlotProps>
XhTimePickerItemvaluestring是两位补零的显示串('09' / '30');上下午列写 '00' / '01'。
XhTimePickerPositionercontainer() => Element | null浮层挂载的容器;未提供时按全局配置,再未提供时挂载到 body。
XhTimePickerPresetvaluestring是该条目的身份,与 presets 数据中的 value 逐字对应。
XhTimePickerPresetGroupchildrenSlotChildren<TimePickerPresetsSlotProps>自行铺设条目;未写时按 presets 数据自动铺设,两者产出的 DOM 一致。
XhTimePickerRootchildrenSlotChildren<TimePickerRootSlotProps>
XhTimePickerSegmentsegmentTimeSegmentType是段的身份由作者声明。

状态 ​

公开状态写入 data-state。

部件取值
root'open' | 'closed'
control'open' | 'closed'
trigger'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'
preset'checked' | 'unchecked'
column'open' | 'closed'
item'checked' | 'unchecked'

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

状态:open · closed

事件:OPEN · TOGGLE · CLOSE · CONTROLLED.OPEN · CONTROLLED.CLOSE · VALUE.SET · VALUE.CLEAR · SEGMENT.STEP · SEGMENT.DIGIT · SEGMENT.CLEAR · SEGMENT.PERIOD · SEGMENT.FOCUS · SEGMENT.BLUR · OPTION.FOCUS · ITEM.SELECT · FORM.RESET · PRESS.START · PRESS.END

判据:isOpenControlled · canEdit · closesOnPreset · canPress

connect API ​

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

成员类型说明
openboolean
valuestringISO 时间串;任一必填段为空时为空串。
emptyboolean值为空串(尚未填全)。
outOfRangeboolean已填全但落在 min / max 之外。只是标注,不改写值。
disabledboolean
readOnlyboolean
invalidboolean
hourCycleTimeHourCycle实际生效的小时制(prop 未提供时由 locale 推断的值)。
granularityTimeGranularity
stepnumber实际生效的分列步进。
segmentsTimeSegmentType[]当前参与显示的段,文档序。未列入的段由 connect 写上 hidden 收起。
focusedSegmentTimeSegmentType | null焦点所在段;焦点在分段输入外时为 null。
columnsTimePickerColumn[]当前应排列的列及每列的可选值(已按 step 与 min / max 裁剪)。作者据此渲染浮层。
focusedColumnTimePickerColumnUnit | null
focusedItemstring | null
presetsreadonly TimePickerPresetState[]快捷选项逐条的状态,数据顺序。未提供 presets 时为空数组。
canClearboolean清空按钮当前是否可按。
getSegmentText(props: TimePickerSegmentProps) => string某一段应显示的文字(空段是占位串)。各适配器都用它填充文本,保证同构。
getItemText(props: TimePickerItemProps) => string某一格应显示的文字。数字列即格子自身的值,上下午列按 locale 给出「上午 / 下午」。 各适配器都用它填充文本,保证同构。
isItemSelected(props: TimePickerItemProps) => boolean
isItemDisabled(props: TimePickerItemProps) => boolean落在 min / max 之外(或整个控件禁用):仍在列表中,但不可选、方向键跳过。
setOpen(next: boolean) => void
setValue(next: string) => void
clear() => void
getRootProps() => T['element']
getLabelProps() => T['label']
getControlProps() => T['element']
getSegmentGroupProps() => T['element']段位与分隔符的外壳:占满盒内剩余宽度,把尾部按钮推到框内末端。
getSegmentProps(props: TimePickerSegmentProps) => T['element']分段输入:一段一个节点,与 TimeField 的段同构(role=spinbutton + roving tabindex)。
getTriggerProps() => T['button']
getClearTriggerProps() => T['button']
getPositionerProps() => T['element']
getContentProps() => T['element']
getPresetGroupProps() => T['element']快捷选项列(role=listbox);未提供 presets 时带 hidden。
getPresetProps(props: TimePickerPresetProps) => T['element']一条快捷选项(role=option):点击把整份时间写入值并收起浮层。
getColumnProps(props: TimePickerColumnProps) => T['element']
getItemProps(props: TimePickerItemProps) => T['element']
getHiddenInputProps() => T['input']表单出口:一份 type=hidden 的原生输入,随表单提交 ISO 串。

无障碍 ​

键盘 ​

规格出处:W3C APG

按键生效条件行为
ArrowDown / ArrowUpfocus in trigger, closed, not disabled展开浮层,焦点落到时列(已选的时仍可选就停在它上面,否则停在首格)
Enter / Spacefocus in trigger, not disabled按钮的默认激活即展开/收起(不额外拦键,否则会一开一关)
ArrowDownopen, focus in 某一列列内下移一格,到尾回绕;被 min/max 裁掉的格自动跳过
ArrowUpopen, focus in 某一列列内上移一格,到头回绕;被 min/max 裁掉的格自动跳过
Homeopen, focus in 某一列焦点移到本列首格
Endopen, focus in 某一列焦点移到本列末格
ArrowRightopen换到下一列并落在该列的锚点上;已在末列则不动,不回绕
ArrowLeftopen换到上一列并落在该列的锚点上;已在首列则不动,不回绕
Enter / Spaceopen, 焦点停在可选的格上, not disabled/readOnly把这一格写进对应的段;浮层不收起(其余列还要接着挑)
ArrowUp / ArrowDown / Home / Endopen, focus in 快捷选项列在快捷选项之间移动焦点,到头回绕;时分秒那几列的处理器在这一列内不参与
Enter / Spaceopen, focus in 某条快捷选项, not disabled/readOnly把这条快捷选项整份写进值并收起浮层
Escapeopen收起浮层并把焦点归还触发器,值不变
Tab / Shift+Tabopen收起浮层且不拦按键,焦点按 Tab 序列自然离开,不抢回触发器
ArrowUpfocus in 某一段, not disabled/readOnly本段加一格,到头回绕;空段落到该段下界
ArrowDownfocus in 某一段, not disabled/readOnly本段减一格,到头回绕;空段落到该段上界
ArrowRightfocus in 某一段, not disabled焦点移到下一段;已在末段则不动,不回绕
ArrowLeftfocus in 某一段, not disabled焦点移到上一段;已在首段则不动,不回绕
Homefocus in 某一段, not disabled焦点移到首段
Endfocus in 某一段, not disabled焦点移到末段
0-9focus in 数字段, not disabled/readOnly把数字并进本段;本段再吃不下第二位时自动跳到下一段
Backspace / Deletefocus in 某一段, not disabled/readOnly清掉本段;小时被清时上下午段仍保留原来的上午/下午
a / pfocus in 上下午段, 12 小时制, not disabled/readOnlya 取上午、p 取下午(不区分大小写)
Alt+ArrowDownfocus in 某一段, closed, not disabled展开浮层并把焦点移入;触发按钮是可选部件,键盘入口不能只挂在它上面
Enterfocus in 某一段, open收起浮层。段位里敲出来的值不触发「选完即收」(那时人还在打字),这是那条路的收口手势
Enter / Spaceheld on trigger(not disabled)、clear-trigger(可清)、preset 或 item(open, not disabled/readOnly, 该条可按)按住期间该部件投影 data-pressed,与指针 :active 同一副按压面;抬起或失焦撤下,浮层收起时一并撤下

ARIA ​

以下属性由 connect 生成。

部件属性值
controlaria-disabled'true' | 'false'
controlaria-invalid'true' | 'false'
controlaria-labelledbylabel 部件的 id
controlrole'group'
segmentaria-disabled'true' | 'false'
segmentaria-invalid'true' | 'false'
segmentaria-labelprop('translations')?.[segment]
segmentaria-readonly'true' | 'false'
segmentaria-required'true' | 'false'
segmentaria-valuemaxrange.max
segmentaria-valueminrange.min
segmentaria-valuenowsegmentNumber(draft, segment, hourCycle)
segmentaria-valuetexttimeSegmentText(draft, segment, { hourCycle, locale })
segmentrole'spinbutton'
triggeraria-controlscontent 部件的 id
triggeraria-expanded'true' | 'false'
triggeraria-haspopup'dialog'
triggeraria-labelledbylabel 部件的 id
clear-triggeraria-labelprops.translations.clearTrigger
contentaria-hidden!open || undefined
contentaria-labelledbylabel 部件的 id
contentaria-modal'false'
contentrole'dialog'
preset-grouparia-disabled'true' | 'false'
preset-grouparia-labelprops.translations.presets
preset-grouparia-multiselectable'false'
preset-grouparia-orientation'vertical'
preset-grouprole'listbox'
presetaria-disabled'true' | 'false'
presetaria-selected'true' | 'false'
presetrole'option'
columnaria-disabled'true' | 'false'
columnaria-labelprop('translations')?.[unit]
columnaria-multiselectable'false'
columnaria-orientation'vertical'
columnrole'listbox'
itemaria-disabled'true' | 'false'
itemaria-selected'true' | 'false'
itemrole'option'

样式参考 ​

皮肤 ​

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

forced-colors: active 下另有一套规则:颜色交给系统,边框与状态标记改用系统色关键字。

数据属性 ​

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

部件属性值
rootdata-disabled''(条件成立时才出现)
rootdata-empty''(条件成立时才出现)
rootdata-invalid''(条件成立时才出现)
rootdata-out-of-range''(条件成立时才出现)
rootdata-readonly''(条件成立时才出现)
rootdata-sizeprops.size
rootdata-state'open' | 'closed'
rootdata-toneprops.tone
rootdata-variantprops.variant
labeldata-disabled''(条件成立时才出现)
controldata-disabled''(条件成立时才出现)
controldata-empty''(条件成立时才出现)
controldata-invalid''(条件成立时才出现)
controldata-readonly''(条件成立时才出现)
controldata-state'open' | 'closed'
controldata-variantprops.variant
controldata-xh-field-chrome''
controldata-xh-field-sizeprops.size
segment-groupdata-disabled''(条件成立时才出现)
segment-groupdata-invalid''(条件成立时才出现)
segment-groupdata-readonly''(条件成立时才出现)
segmentdata-disabled''(条件成立时才出现)
segmentdata-focus''(条件成立时才出现)
segmentdata-invalid''(条件成立时才出现)
segmentdata-placeholder''(条件成立时才出现)
segmentdata-readonly''(条件成立时才出现)
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'
presetdata-disabled''(条件成立时才出现)
presetdata-pressed''(条件成立时才出现)
presetdata-state'checked' | 'unchecked'
presetdata-xh-collection-context'overlay'
presetdata-xh-collection-item''
presetdata-xh-collection-sizeprops.size
columndata-disabled''(条件成立时才出现)
columndata-state'open' | 'closed'
itemdata-disabled''(条件成立时才出现)
itemdata-highlighted''(条件成立时才出现)
itemdata-pressed''(条件成立时才出现)
itemdata-state'checked' | 'unchecked'
itemdata-xh-collection-context'overlay'
itemdata-xh-collection-item''
itemdata-xh-collection-sizeprops.size

CSS 变量 ​

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

变量部件CSS 属性状态默认来源说明
--xh-time-picker-action-bgclear-trigger
trigger
--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-resttime-picker 的 clear-trigger、trigger 部件 --xh-ink-surface、background-color 覆盖槽。
--xh-time-picker-action-bg-activeclear-trigger
trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressedtime-picker 的 clear-trigger、trigger 部件 background-color 覆盖槽。
--xh-time-picker-action-bg-hoverclear-trigger
trigger
--xh-ink-surface
background-color
disabled
hover
loading
not([data-disabled])
not([data-loading])
state=open
xh-ink-surface
--xh-_action-variant-bg-hovertime-picker 的 clear-trigger、trigger 部件 --xh-ink-surface、background-color 覆盖槽。
--xh-time-picker-action-fgclear-trigger
trigger
colordefault--xh-fg-mutedtime-picker 的 clear-trigger、trigger 部件 color 覆盖槽。
--xh-time-picker-action-fg-hoverclear-trigger
trigger
colordisabled
hover
loading
not([data-disabled])
not([data-loading])
state=open
--xh-fg-defaulttime-picker 的 clear-trigger、trigger 部件 color 覆盖槽。
--xh-time-picker-action-font-sizeclear-trigger
trigger
font-sizedefault--xh-text-secondary-sizetime-picker 的 clear-trigger、trigger 部件 font-size 覆盖槽。
--xh-time-picker-action-radiusclear-trigger
trigger
border-radiusdefault--xh-shape-insettime-picker 的 clear-trigger、trigger 部件 border-radius 覆盖槽。
--xh-time-picker-action-sizeclear-trigger
trigger
block-size
inline-size
min-inline-size
default
xh-action-profile=field-inset
--xh-_action-profile-visual-sizetime-picker 的 clear-trigger、trigger 部件 block-size、inline-size、min-inline-size 覆盖槽。
--xh-time-picker-column-dividercolumn
preset-group
border-inline-end
border-inline-start
default--xh-material-frosted-separatortime-picker 的 column、preset-group 部件 border-inline-end、border-inline-start 覆盖槽。
--xh-time-picker-column-gapcolumngapdefault0time-picker 的 column 部件 gap 覆盖槽。
--xh-time-picker-column-hcolumnblock-sizedefault--xh-viewport-h-smtime-picker 的 column 部件 block-size 覆盖槽。
--xh-time-picker-column-min-wcolumnmin-inline-sizedefault--xh-overlay-column-min-wtime-picker 的 column 部件 min-inline-size 覆盖槽。
--xh-time-picker-column-pxcolumnpadding-inlinedefault0time-picker 的 column 部件 padding-inline 覆盖槽。
--xh-time-picker-content-bgcontentbackgrounddefault--xh-bg-surfacetime-picker 的 content 部件 background 覆盖槽。
--xh-time-picker-content-bordercontentborderdefault--xh-border-defaulttime-picker 的 content 部件 border 覆盖槽。
--xh-time-picker-content-fgcontentcolordefault--xh-fg-defaulttime-picker 的 content 部件 color 覆盖槽。
--xh-time-picker-content-max-hcontentmax-block-sizedefault--xh-viewport-h-lgtime-picker 的 content 部件 max-block-size 覆盖槽。
--xh-time-picker-content-pxcontentpadding-inlinedefault--xh-space-1time-picker 的 content 部件 padding-inline 覆盖槽。
--xh-time-picker-content-pycontentpadding-blockdefault--xh-space-1time-picker 的 content 部件 padding-block 覆盖槽。
--xh-time-picker-content-radiuscontentborder-radiusdefault--xh-shape-overlaytime-picker 的 content 部件 border-radius 覆盖槽。
--xh-time-picker-content-shadowcontentbox-shadowdefault--xh-elevation-floatingtime-picker 的 content 部件 box-shadow 覆盖槽。
--xh-time-picker-control-bgcontrolbackground-colorxh-field-chrome--xh-_field-variant-bg-resttime-picker 的 control 部件 background-color 覆盖槽。
--xh-time-picker-control-bg-disabledcontrolbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabledtime-picker 的 control 部件 background-color 覆盖槽。
--xh-time-picker-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-hovertime-picker 的 control 部件 background-color 覆盖槽。
--xh-time-picker-control-bg-readonlycontrolbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-onlytime-picker 的 control 部件 background-color 覆盖槽。
--xh-time-picker-control-bordercontrolborderxh-field-chrome--xh-_field-variant-border-resttime-picker 的 control 部件 border 覆盖槽。
--xh-time-picker-control-border-focuscontrolborder-colordisabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focustime-picker 的 control 部件 border-color 覆盖槽。
--xh-time-picker-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-hovertime-picker 的 control 部件 border-color 覆盖槽。
--xh-time-picker-control-border-invalidcontrolborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalidtime-picker 的 control 部件 border-color 覆盖槽。
--xh-time-picker-control-fgcontrolcolorxh-field-chrome--xh-fg-defaulttime-picker 的 control 部件 color 覆盖槽。
--xh-time-picker-control-gapcontrolgapxh-field-chrome--xh-_time-picker-gaptime-picker 的 control 部件 gap 覆盖槽。
--xh-time-picker-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-_time-picker-control-htime-picker 的 control 部件 block-size、min-block-size 覆盖槽。
--xh-time-picker-control-min-wcontrol
root
min-inline-sizedefault
xh-field-chrome
--xh-control-min-wtime-picker 的 control、root 部件 min-inline-size 覆盖槽。
--xh-time-picker-control-pxcontrolpadding-inlinexh-field-chrome--xh-_time-picker-control-pxtime-picker 的 control 部件 padding-inline 覆盖槽。
--xh-time-picker-control-radiuscontrolborder-radiusxh-field-chrome--xh-shape-controltime-picker 的 control 部件 border-radius 覆盖槽。
--xh-time-picker-control-shadowcontrolbox-shadowxh-field-chromenonetime-picker 的 control 部件 box-shadow 覆盖槽。
--xh-time-picker-control-wrootinline-size
min-inline-size
default--xh-control-wtime-picker 的 root 部件 inline-size、min-inline-size 覆盖槽。
--xh-time-picker-font-sizecontrolfont-sizedefault--xh-_time-picker-font-sizetime-picker 的 control 部件 font-size 覆盖槽。
--xh-time-picker-gaprootgapdefault--xh-space-1time-picker 的 root 部件 gap 覆盖槽。
--xh-time-picker-icon-sizecontrol
positioner
root
--xh-icon-sizedefault
is([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
time-picker 的 control、positioner、root 部件 --xh-icon-size 覆盖槽。
--xh-time-picker-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-subtletime-picker 的 item 部件 background-color 覆盖槽。
--xh-time-picker-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-hovertime-picker 的 item 部件 background-color 覆盖槽。
--xh-time-picker-item-check-fgitembackground-colordefault--xh-_time-picker-check-fgtime-picker 的 item 部件 background-color 覆盖槽。
--xh-time-picker-item-check-sizeitemblock-size
inline-size
padding-inline
default--xh-glyph-size-smtime-picker 的 item 部件 block-size、inline-size、padding-inline 覆盖槽。
--xh-time-picker-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-fgtime-picker 的 item 部件 color 覆盖槽。
--xh-time-picker-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-time-picker-item-fgtime-picker 的 item 部件 color 覆盖槽。
--xh-time-picker-item-font-sizeitemfont-sizedefault--xh-_time-picker-font-sizetime-picker 的 item 部件 font-size 覆盖槽。
--xh-time-picker-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-regulartime-picker 的 item 部件 font-weight 覆盖槽。
--xh-time-picker-item-hitemblock-sizedefault--xh-overlay-column-item-htime-picker 的 item 部件 block-size 覆盖槽。
--xh-time-picker-item-pxitempadding-inlinedefault--xh-space-0_5time-picker 的 item 部件 padding-inline 覆盖槽。
--xh-time-picker-item-pyitempadding-blockdefault0time-picker 的 item 部件 padding-block 覆盖槽。
--xh-time-picker-item-radiusitemborder-radiusdefault--xh-shape-controltime-picker 的 item 部件 border-radius 覆盖槽。
--xh-time-picker-label-fglabelcolordefault--xh-fg-defaulttime-picker 的 label 部件 color 覆盖槽。
--xh-time-picker-label-fg-disabledlabelcolordisabled--xh-fg-subtletime-picker 的 label 部件 color 覆盖槽。
--xh-time-picker-label-font-sizelabelfont-sizedefault--xh-text-label-sizetime-picker 的 label 部件 font-size 覆盖槽。
--xh-time-picker-label-font-weightlabelfont-weightdefault--xh-text-label-weighttime-picker 的 label 部件 font-weight 覆盖槽。
--xh-time-picker-layerpositionerz-indexdefault--xh-_layertime-picker 的 positioner 部件 z-index 覆盖槽。
--xh-time-picker-literal-fgsegment-groupcolornot([data-scope])--xh-fg-subtletime-picker 的 segment-group 部件 color 覆盖槽。
--xh-time-picker-placeholder-fgsegmentcolorplaceholder--xh-fg-subtletime-picker 的 segment 部件 color 覆盖槽。
--xh-time-picker-preset-bg-hoverpresetbackground-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-subtletime-picker 的 preset 部件 background-color 覆盖槽。
--xh-time-picker-preset-bg-pressedpresetbackground-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-hovertime-picker 的 preset 部件 background-color 覆盖槽。
--xh-time-picker-preset-check-fgpresetbackground-colordefault--xh-_time-picker-check-fgtime-picker 的 preset 部件 background-color 覆盖槽。
--xh-time-picker-preset-check-sizepresetblock-size
inline-size
padding-inline-end
default--xh-glyph-size-smtime-picker 的 preset 部件 block-size、inline-size、padding-inline-end 覆盖槽。
--xh-time-picker-preset-fgpresetcolordefault
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-fg-defaulttime-picker 的 preset 部件 color 覆盖槽。
--xh-time-picker-preset-fg-checkedpresetcolordisabled
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-time-picker-preset-fgtime-picker 的 preset 部件 color 覆盖槽。
--xh-time-picker-preset-fg-disabledpresetbackground-color
color
default
disabled
--xh-fg-disabledtime-picker 的 preset 部件 background-color、color 覆盖槽。
--xh-time-picker-preset-group-gappreset-groupgapdefault--xh-list-option-gaptime-picker 的 preset-group 部件 gap 覆盖槽。
--xh-time-picker-preset-group-hpreset-groupmax-block-sizedefault--xh-viewport-h-smtime-picker 的 preset-group 部件 max-block-size 覆盖槽。
--xh-time-picker-preset-group-pxpreset-grouppadding-inlinedefault--xh-space-1time-picker 的 preset-group 部件 padding-inline 覆盖槽。
--xh-time-picker-preset-pxpresetinset-inline-end
padding-inline
padding-inline-end
default--xh-space-3time-picker 的 preset 部件 inset-inline-end、padding-inline、padding-inline-end 覆盖槽。
--xh-time-picker-preset-pypresetpadding-blockdefault--xh-space-1time-picker 的 preset 部件 padding-block 覆盖槽。
--xh-time-picker-preset-radiuspresetborder-radiusdefault--xh-shape-controltime-picker 的 preset 部件 border-radius 覆盖槽。
--xh-time-picker-segment-bg-focussegmentbackgrounddisabled
focus
focus-visible
not([data-disabled])
--xh-_time-picker-segment-bgtime-picker 的 segment 部件 background 覆盖槽。
--xh-time-picker-segment-bg-hoversegmentbackgrounddisabled
focus
hover
not([data-focus], [data-disabled])
--xh-bg-subtletime-picker 的 segment 部件 background 覆盖槽。
--xh-time-picker-segment-bg-invalid-focussegmentbackgroundfocus
invalid
is([data-focus], :focus-visible)
--xh-bg-subtletime-picker 的 segment 部件 background 覆盖槽。
--xh-time-picker-segment-fg-focussegmentcolordisabled
focus
focus-visible
not([data-disabled])
placeholder
--xh-_time-picker-segment-fgtime-picker 的 segment 部件 color 覆盖槽。
--xh-time-picker-segment-fg-invalidsegmentcolorinvalid--xh-fg-dangertime-picker 的 segment 部件 color 覆盖槽。
--xh-time-picker-segment-fg-invalid-focussegmentcolorfocus
invalid
is([data-focus], :focus-visible)
--xh-fg-dangertime-picker 的 segment 部件 color 覆盖槽。
--xh-time-picker-segment-pxsegmentpadding-inlinedefault--xh-space-0_5time-picker 的 segment 部件 padding-inline 覆盖槽。
--xh-time-picker-segment-radiussegmentborder-radiusdefault--xh-shape-insettime-picker 的 segment 部件 border-radius 覆盖槽。

动效 ​

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

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

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

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

RTL ​

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

Released under The MIT License