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

查看生态总览
Skip to content

Popover ​

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="popover": trigger · positioner · content · title · description · close-trigger · 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-popover>
Vue componentsXhPopoverArrow XhPopoverCloseTrigger XhPopoverContent XhPopoverDescription XhPopoverPositioner XhPopoverRoot XhPopoverTitle XhPopoverTrigger
ComposableusePopover
State machinepopoverMachine
Skin@xihan-ui/styles/popover.css

Props ​

PropTypeRequired
openboolean
defaultOpenboolean
anchorHTMLElement | null
placementPlacement
dirDirection
offsetnumber
modalboolean
closeOnEscapeboolean
closeOnInteractOutsideboolean
disabledboolean
partsTitleDescriptionParts
translationsPartial<PopoverTranslations>
sizeSize
onOpenChange(details: PopoverOpenChangeDetails) => void

Events ​

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

EventPayload
open-changePopoverOpenChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhPopoverRootdefaultPopoverRootSlotProps

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
XhPopoverPositionercontainer() => Element | null
XhPopoverRootchildrenSlotChildren<PopoverRootSlotProps>

State ​

Public state is written to data-state.

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

The following names are internal to the state machine.

States: open · closed

Events: OPEN · TOGGLE · CLOSE · CONTROLLED.OPEN · CONTROLLED.CLOSE · PRESS.START · PRESS.END

Guards: isOpenControlled · isDisabled

connect API ​

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

MemberType
openboolean
setOpen(next: boolean) => void
getTriggerProps() => T['button']
getPositionerProps() => T['element']
getContentProps() => T['element']
getTitleProps() => T['element']
getDescriptionProps() => T['element']
getCloseTriggerProps() => T['button']
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
Enter / Spacepopover.kbd.toggle-on-trigger
Escapepopover.kbd.escape
Tabpopover.kbd.tab
Shift+Tabpopover.kbd.shift-tab
Enter / Spacepopover.kbd.press

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 | undefined
contentaria-modal'true' | 'false'
contentrole'dialog'
close-triggeraria-labeltranslations.close
arrowaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/popover.css is written against [data-scope="popover"][data-part="trigger"] part selectors; the published build uses the mount class .xh-scope-popover 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
triggerdata-disabled'' (present only while the condition holds)
triggerdata-pressed'' (present only while the condition holds)
triggerdata-state'open' | 'closed'
triggerdata-xh-action-control''
triggerdata-xh-action-display'always'
triggerdata-xh-action-profile'text'
triggerdata-xh-action-size'md'
triggerdata-xh-action-variant'outline'
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'
close-triggerdata-pressed'' (present only while the condition holds)
close-triggerdata-xh-action-control''
close-triggerdata-xh-action-display'always'
close-triggerdata-xh-action-profile'icon'
close-triggerdata-xh-action-size'sm'
close-triggerdata-xh-action-variant'ghost'
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-popover-arrow-sizearrow--xh-_overlay-arrow-sizedefault--xh-overlay-arrow-size
--xh-popover-backdropcontent-webkit-backdrop-filter
backdrop-filter
xh-material=frosted--xh-_material-backdrop
--xh-popover-bgarrow
content
backgrounddefault
not([data-xh-action-control])
xh-material=frosted
--xh-_material-bg
--xh-material-frosted-bg
--xh-popover-borderarrow
content
borderdefault
not([data-xh-action-control])
xh-material=frosted
--xh-_material-border
--xh-material-frosted-border
--xh-popover-close-bg-activeclose-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-popover-close-bg-focusclose-triggerbackground-colorfocus-visible--xh-_action-variant-bg-focus-visible
--xh-popover-close-bg-hoverclose-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-popover-close-fgclose-triggercolordefault--xh-material-frosted-fg-muted
--xh-popover-close-fg-focusclose-triggercolorfocus-visible--xh-popover-close-fg-hover
--xh-popover-close-fg-hoverclose-triggercolordisabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-focus-visible
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-popover-close-radiusclose-triggerborder-radiusdefault--xh-shape-control
--xh-popover-close-sizeclose-trigger
content
title
block-size
inline-size
padding-inline-end
default
has([data-scope='popover'][data-part='close-trigger'])
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-control-h-sm
--xh-popover-description-fgdescriptioncolordefault--xh-fg-muted
--xh-popover-description-font-sizedescriptionfont-sizedefault--xh-text-body-size
--xh-popover-fgcontentcolornot([data-xh-action-control])
xh-material=frosted
--xh-_material-fg
--xh-popover-gapcontentgapdefault--xh-space-1
--xh-popover-icon-sizeclose-trigger
content
trigger
--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-glyph-size-md
--xh-popover-layerpositionerz-indexdefault--xh-_layer
--xh-popover-max-hcontentmax-block-sizedefault--xh-overlay-max-h
--xh-popover-max-wcontentmax-inline-sizedefault--xh-_popover-max-w
--xh-popover-pxcontentpadding-inlinedefault--xh-_popover-px
--xh-popover-pycontentpadding-blockdefault--xh-_popover-py
--xh-popover-radiuscontentborder-radiusdefault--xh-shape-overlay
--xh-popover-shadowcontentbox-shadownot([data-xh-action-control])
xh-material=frosted
--xh-_material-shadow
--xh-popover-title-fgtitlecolordefault--xh-material-frosted-fg
--xh-popover-title-font-sizetitlefont-sizedefault--xh-text-label-size
--xh-popover-title-font-weighttitlefont-weightdefault--xh-font-weight-medium

Released under The MIT License