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

查看生态总览
Skip to content

Kbd ​

General 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="kbd": root · key

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-kbd>
Vue componentsXhKbd
State machineNone: connect computes attributes from props directly
Skin@xihan-ui/styles/kbd.css

Props ​

PropTypeRequired
enabledboolean
keysstring[]Yes
onHotKey(details: KbdTriggerDetails) => void
platformKbdPlatform
preventDefaultboolean
registerboolean
targetKbdTarget
translationsPartial<KbdTranslations>
variantKbdVariant

Events ​

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

EventPayload
hot-keyKbdTriggerDetails

connect API ​

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

MemberType
segmentsreadonly HotkeySegment[]
platformKbdResolvedPlatform
registerboolean
enabledboolean
targetKbdTarget
resolveTarget(documentTarget: EventTarget | null) => EventTarget | null
matches(event: KeyboardEvent) => boolean
handleKeyDown(event: KeyboardEvent) => void
getRootProps() => T['element']
getKeyProps(props: KbdKeyProps) => T['element']

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
the combination given by keyskbd.keydown.trigger
the combination given by keyskbd.keydown.typing

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-labeltranslations.hotkey(names)
rootrole'img'
keyaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/kbd.css is written against [data-scope="kbd"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-kbd 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-platformresolveKbdPlatform(props.platform)
rootdata-register'' (present only while the condition holds)
rootdata-variantprops.variant
keydata-keysegmentOf(value)?.key

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-kbd-bgrootbackgrounddefault--xh-bg-subtle
--xh-kbd-borderrootborderdefaulttransparent
--xh-kbd-fgrootcolordefault--xh-fg-muted
--xh-kbd-fg-disabledrootcolordisabled--xh-fg-disabled
--xh-kbd-fontrootfont-familydefaultinherit
--xh-kbd-font-sizerootfont-sizedefault--xh-text-caption-size
--xh-kbd-font-weightrootfont-weightdefault--xh-font-weight-regular
--xh-kbd-gaprootgapdefault--xh-space-1
--xh-kbd-hrootblock-sizedefault--xh-space-6
--xh-kbd-min-wrootmin-inline-sizedefault--xh-space-6
--xh-kbd-pxrootpadding-inlinedefault--xh-space-2
--xh-kbd-radiusrootborder-radiusdefault--xh-shape-control

Released under The MIT License