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

查看生态总览
Skip to content

HoverCard ​

Overlays 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="hover-card": root · trigger · positioner · content · title · description · arrow

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-hover-card>
Vue componentsXhHoverCardArrow XhHoverCardContent XhHoverCardDescription XhHoverCardPositioner XhHoverCardRoot XhHoverCardTitle XhHoverCardTrigger
ComposableuseHoverCard
State machinehoverCardMachine
Skin@xihan-ui/styles/hover-card.css

Props ​

PropTypeRequired
openboolean
defaultOpenboolean
placementPlacement
offsetnumber
openDelaynumber
closeDelaynumber
dirDirection
partsTitleDescriptionParts
disabledboolean
sizeSize
onOpenChange(details: HoverCardOpenChangeDetails) => void

Events ​

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

EventPayload
open-changeHoverCardOpenChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhHoverCardRootdefaultHoverCardRootSlotProps

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
XhHoverCardPositionercontainer() => Element | null
XhHoverCardRootchildrenSlotChildren<HoverCardRootSlotProps>

State ​

Public state is written to data-state.

PartValues
root'open' | 'closed'
trigger'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'

The following names are internal to the state machine.

States: closed · opening · visible · visible.open · visible.closing

Events: POINTER.ENTER · POINTER.LEAVE · FOCUS · BLUR · ESCAPE · OPEN · CLOSE · after.openDelay · after.closeDelay · CONTROLLED.OPEN · CONTROLLED.CLOSE

Guards: isOpenControlled · isDisabled · isFocusHeld

connect API ​

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

MemberType
openboolean
setOpen(next: boolean) => void
getRootProps() => T['element']
getTriggerProps() => T['button']
getPositionerProps() => T['element']
getContentProps() => T['element']
getTitleProps() => T['element']
getDescriptionProps() => T['element']
getArrowProps() => 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
Tab / Shift+Tabhover-card.kbd.focus-trigger
Escapehover-card.kbd.escape

ARIA ​

These attributes are produced by connect.

PartAttributeValue
triggeraria-controlsid of the content part
triggeraria-expanded'true' | 'false'
triggeraria-haspopup'dialog'
contentaria-describedbyid of the description part | undefined
contentaria-hidden!open || undefined
contentaria-labelledbyid of the title part | id of the trigger part
contentaria-modal'false'
contentrole'dialog'
arrowaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/hover-card.css is written against [data-scope="hover-card"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-hover-card 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-state'open' | 'closed'
triggerdata-disabled'' (present only while the condition holds)
triggerdata-state'open' | 'closed'
positionerdata-hidden'' (present only while the condition holds)
positionerdata-placementactual placement computed by the positioning engine
positionerdata-positioned'' (present only while the condition holds)
positionerdata-state'open' | 'closed'
contentdata-instant'' (present only while the condition holds)
contentdata-placementactual placement computed by the positioning engine
contentdata-sizeprops.size
contentdata-state'open' | 'closed'
contentdata-xh-material'frosted'
arrowdata-placementactual placement computed by the positioning engine

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-hover-card-arrow-sizearrow--xh-_overlay-arrow-sizedefault--xh-overlay-arrow-size
--xh-hover-card-backdropcontent-webkit-backdrop-filter
backdrop-filter
xh-material=frosted--xh-_material-backdrop
--xh-hover-card-bgarrow
content
backgrounddefault
not([data-xh-action-control])
xh-material=frosted
--xh-_material-bg
--xh-material-frosted-bg
--xh-hover-card-borderarrow
content
borderdefault
not([data-xh-action-control])
xh-material=frosted
--xh-_material-border
--xh-material-frosted-border
--xh-hover-card-description-fgdescriptioncolordefault--xh-fg-muted
--xh-hover-card-description-font-sizedescriptionfont-sizedefault--xh-text-body-size
--xh-hover-card-fgcontentcolornot([data-xh-action-control])
xh-material=frosted
--xh-_material-fg
--xh-hover-card-gapcontentgapdefault--xh-space-1
--xh-hover-card-layerpositionerz-indexdefault--xh-_layer
--xh-hover-card-max-hcontentmax-block-sizedefault--xh-overlay-max-h
--xh-hover-card-max-wcontentmax-inline-sizedefault--xh-_hover-card-max-w
--xh-hover-card-pxcontentpadding-inlinedefault--xh-_hover-card-px
--xh-hover-card-pycontentpadding-blockdefault--xh-_hover-card-py
--xh-hover-card-radiuscontentborder-radiusdefault--xh-shape-overlay
--xh-hover-card-shadowcontentbox-shadownot([data-xh-action-control])
xh-material=frosted
--xh-_material-shadow
--xh-hover-card-title-fgtitlecolordefault--xh-fg-default
--xh-hover-card-title-font-sizetitlefont-sizedefault--xh-text-label-size
--xh-hover-card-title-font-weighttitlefont-weightdefault--xh-font-weight-medium
--xh-hover-card-trigger-gaptriggergapdefault--xh-control-gap-sm

Released under The MIT License