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

查看生态总览
Skip to content

ToolCall alpha ​

AI chat 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="tool-call": root · trigger · indicator · label · summary · status · duration · approval · content · input · output · error

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-tool-call>
Vue componentsXhToolCallApproval XhToolCallContent XhToolCallDuration XhToolCallError XhToolCallIndicator XhToolCallInput XhToolCallLabel XhToolCallOutput XhToolCallRoot XhToolCallStatus XhToolCallSummary XhToolCallTrigger
ComposableuseToolCall
State machinetoolCallMachine
Skin@xihan-ui/styles/tool-call.css

Props ​

PropTypeRequired
runningboolean
openboolean
defaultOpenboolean
autoDisclosureboolean
disabledboolean
clockboolean
onOpenChange(details: ToolCallOpenChangeDetails) => void
endTimenumber
phaseToolCallPhase
sizeSize
startTimenumber
toneTone
translationsPartial<ToolCallTranslations>
variantControlVariant

Events ​

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

EventPayload
open-changeToolCallOpenChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhToolCallRootdefaultToolCallRootSlotProps

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
XhToolCallRootchildrenSlotChildren<ToolCallRootSlotProps>

State ​

Public state is written to data-state.

PartValues
root'open' | 'closed'
trigger'open' | 'closed'
indicator'open' | 'closed'
labelprops.phase
summaryprops.phase
statusprops.phase
durationprops.phase
approvalprops.phase
content'open' | 'closed'
inputprops.phase
outputprops.phase
errorprops.phase

The following names are internal to the state machine.

States: auto.collapsed · auto.expanded · held.collapsed · held.expanded

Events: TOGGLE · OPEN · CLOSE · PHASE.ACTIVE · PHASE.SETTLE · CONTROLLED.OPEN · CONTROLLED.CLOSE · PRESS.START · PRESS.END

Guards: isOpenControlled · isAutoAllowed · isAutoEnabled · canPress

connect API ​

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

MemberType
openboolean
phaseToolCallPhase
runningboolean
settledboolean
erroredboolean
disabledboolean
statusTextstring
durationMsnumber | undefined
setOpen(next: boolean) => void
getRootProps() => T['element']
getTriggerProps() => T['button']
getIndicatorProps() => T['element']
getLabelProps() => T['element']
getSummaryProps() => T['element']
getStatusProps() => T['element']
getDurationProps() => T['element']
getApprovalProps() => T['element']
getContentProps() => T['element']
getInputProps() => T['element']
getOutputProps() => T['element']
getErrorProps() => 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 / Spacetool-call.kbd.toggle
Enter / Spacetool-call.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
triggeraria-controlsid of the content part
triggeraria-describedbyid of the error part | undefined
triggeraria-expanded'true' | 'false'
indicatoraria-hidden'true'
contentaria-labelledbyid of the trigger part
contentrole'region'

Style reference ​

Skin ​

@xihan-ui/styles/tool-call.css is written against [data-scope="tool-call"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-tool-call in place of data-scope (same specificity) and sits in the xihan.components and xihan.motion layers. 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-errored'' (present only while the condition holds)
rootdata-loading'' (present only while the condition holds)
rootdata-settled'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-state'open' | 'closed'
rootdata-toneprops.tone
rootdata-variantprops.variant
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'disclosure-trigger'
triggerdata-xh-action-sizeprops.size
triggerdata-xh-action-variant'ghost'
indicatordata-instant'' (present only while the condition holds)
indicatordata-state'open' | 'closed'
labeldata-stateprops.phase
summarydata-stateprops.phase
statusdata-stateprops.phase
statusdata-tonestatusTone(phase)
durationdata-loading'' (present only while the condition holds)
durationdata-stateprops.phase
approvaldata-stateprops.phase
contentdata-instant'' (present only while the condition holds)
contentdata-state'open' | 'closed'
inputdata-stateprops.phase
outputdata-stateprops.phase
errordata-stateprops.phase

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-tool-call-bgrootbackgrounddefault
variant=subtle
--xh-bg-subtle
--xh-bg-surface
--xh-tool-call-borderrootborderdefault--xh-border-default
--xh-tool-call-border-errorrootborder-colorerrored
has([data-scope='tool-call'][data-state='output-error'])
state=output-error
--xh-border-invalid
--xh-tool-call-content-gapcontentgapdefault--xh-space-2
--xh-tool-call-dividerapproval
content
border-block-startdefault--xh-border-subtle
--xh-tool-call-duration-fgdurationcolordefault--xh-fg-subtle
--xh-tool-call-error-fgerrorcolordefault--xh-fg-danger
--xh-tool-call-font-sizetriggerfont-sizedefault--xh-_tool-call-font-size
--xh-tool-call-icon-sizeroot
trigger
--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-glyph-size-md
--xh-tool-call-indicator-fgindicatorcolordefault--xh-fg-subtle
--xh-tool-call-label-fontlabel
summary
font-familydefault--xh-font-family-mono
--xh-tool-call-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-tool-call-pxapproval
content
trigger
padding-inlinedefault--xh-_tool-call-px
--xh-tool-call-pyapproval
content
trigger
padding-block
padding-block-end
padding-block-start
@keyframes xh-disclosure-collapse
@keyframes xh-disclosure-expand
default
xh-action-profile=disclosure-trigger
--xh-_tool-call-py
--xh-tool-call-radiusrootborder-radiusdefault--xh-shape-surface
--xh-tool-call-shadowrootbox-shadowdefault
tone
0 0 0 transparent
none
--xh-tool-call-shimmer-durationroot
status
animationloading--xh-motion-loop-shimmer
--xh-tool-call-status-bg-approvalstatusbackgroundstate=awaiting-approval--xh-_tone-subtle
--xh-tool-call-status-bg-donestatusbackgroundstate=output-available--xh-_tone-subtle
--xh-tool-call-status-bg-errorstatusbackgroundstate=output-error--xh-_tone-subtle
--xh-tool-call-status-fgroot
status
color@media (prefers-reduced-motion: reduce)
@media print
default
loading
motion=reduce
where([data-motion='reduce'])
--xh-fg-muted
--xh-tool-call-status-fg-approvalstatuscolorstate=awaiting-approval--xh-_tone-fg
--xh-tool-call-status-fg-donestatuscolorstate=output-available--xh-_tone-fg
--xh-tool-call-status-fg-errorstatuscolorstate=output-error--xh-_tone-fg
--xh-tool-call-status-font-sizeduration
error
status
font-sizedefault--xh-text-caption-size
--xh-tool-call-status-hstatusmin-block-sizetone--xh-chip-h-sm
--xh-tool-call-status-pxstatuspadding-inlinetone--xh-space-1_5
--xh-tool-call-status-pystatuspadding-blocktone0
--xh-tool-call-status-radiusstatusborder-radiustone--xh-shape-control
--xh-tool-call-status-shimmer-baseroot
status
background-imageloading--xh-fg-subtle
--xh-tool-call-status-shimmer-sheenroot
status
background-imageloading--xh-fg-default
--xh-tool-call-summary-bgsummarybackgrounddefault--xh-bg-subtle
--xh-tool-call-summary-fgsummarycolordefault--xh-fg-muted
--xh-tool-call-summary-font-sizesummaryfont-sizedefault--xh-text-caption-size
--xh-tool-call-summary-pxsummarypadding-inlinedefault--xh-space-1_5
--xh-tool-call-summary-radiussummaryborder-radiusdefault--xh-shape-control
--xh-tool-call-tone-barrootbox-shadowtone--xh-stroke-thick
--xh-tool-call-tone-fgrootbox-shadowtone--xh-_tone-soft
--xh-tool-call-trigger-bg-hovertriggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-tool-call-trigger-fgtriggercolordefault--xh-fg-default
--xh-tool-call-trigger-gaptriggergapdefault--xh-space-2
--xh-tool-call-trigger-radiusroot
trigger
border-radiusvariant=ghost--xh-shape-control

Released under The MIT License