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

查看生态总览
Skip to content

Tooltip ​

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="tooltip": trigger · positioner · content · text · shortcut · 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-tooltip>
Vue componentsXhTooltipArrow XhTooltipContent XhTooltipPositioner XhTooltipProvider XhTooltipRoot XhTooltipShortcut XhTooltipText XhTooltipTrigger
ComposableuseTooltip
State machinetooltipMachine
Skin@xihan-ui/styles/tooltip.css

Props ​

PropTypeRequired
openboolean
defaultOpenboolean
placementPlacement
dirDirection
offsetnumber
openDelaynumber
closeDelaynumber
skipDelayDurationnumber
disabledboolean
followCursorboolean
delegatestring
platformKbdPlatform
toneTone
sizeSize
translationsPartial<TooltipTranslations>
onOpenChange(details: TooltipOpenChangeDetails) => void

Events ​

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

EventPayload
open-changeTooltipOpenChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhTooltipRootdefaultTooltipRootSlotProps

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
XhTooltipPositionercontainer() => Element | null
XhTooltipProvideropenDelaynumber
XhTooltipProvidercloseDelaynumber
XhTooltipProviderskipDelayDurationnumber
XhTooltipProviderchildrenReactNode
XhTooltipRootchildrenSlotChildren<TooltipRootSlotProps>

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: closed · opening · visible · visible.open · visible.closing

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

Guards: isOpenControlled · isDisabled · isFocusOpened · hasAnchor

connect API ​

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

MemberType
openboolean
setOpen(next: boolean) => void
delegatedboolean
textstring
shortcutstring | null
getTriggerProps() => T['button']
getPositionerProps() => T['element']
getContentProps() => T['element']
getArrowProps() => T['element']
getTextProps() => T['element']
getShortcutProps() => 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+Tabtooltip.kbd.tab
Escapetooltip.kbd.escape

ARIA ​

These attributes are produced by connect.

PartAttributeValue
triggeraria-describedbyid of the content part | undefined
contentaria-hidden!open || undefined
contentrole'tooltip'
shortcutaria-hidden'true'
arrowaria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/tooltip.css is written against [data-scope="tooltip"][data-part="trigger"] part selectors; the published build uses the mount class .xh-scope-tooltip 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-delegate''
triggerdata-disabled'' (present only while the condition holds)
triggerdata-state'open' | 'closed'
positionerdata-follow-cursor'' (present only while the condition holds)
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-sizeprops.size
contentdata-state'open' | 'closed'
contentdata-toneprops.tone
contentdata-xh-ink-surface'' (present only while the condition holds)
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-tooltip-arrow-sizearrow--xh-_overlay-arrow-sizedefault--xh-overlay-arrow-size
--xh-tooltip-backdropcontent-webkit-backdrop-filter
backdrop-filter
default--xh-material-frosted-compact-backdrop
--xh-tooltip-bgarrow
content
--xh-ink-surface
background
default
xh-ink-surface
--xh-_tooltip-solid
--xh-tooltip-borderarrow
content
borderdefault--xh-_tooltip-border
--xh-tooltip-fgcontentcolordefault--xh-_tooltip-on
--xh-tooltip-font-sizecontentfont-sizedefault--xh-_tooltip-font-size
--xh-tooltip-highlightcontentbox-shadowdefaulttransparent
--xh-tooltip-layerpositionerz-indexdefault--xh-_layer
--xh-tooltip-max-wcontentmax-inline-sizedefault--xh-overlay-max-w
--xh-tooltip-pxcontentpadding-inlinedefault--xh-_tooltip-px
--xh-tooltip-pycontentpadding-blockdefault--xh-_tooltip-py
--xh-tooltip-radiuscontentborder-radiusdefault--xh-shape-control
--xh-tooltip-shadowcontentbox-shadowdefault--xh-material-frosted-compact-shadow
--xh-tooltip-trigger-gaptriggergapdefault--xh-control-gap-sm

Released under The MIT License