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

查看生态总览
Skip to content

PromptInput 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="prompt-input": root · control · input · submit-trigger

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-prompt-input>
Vue componentsXhPromptInputControl XhPromptInputInput XhPromptInputRoot XhPromptInputSubmitTrigger
ComposableusePromptInput
State machinepromptInputMachine
Skin@xihan-ui/styles/prompt-input.css

Props ​

PropTypeRequired
valuestring
defaultValuestring
disabledboolean
loadingboolean
submitKeyPromptInputSubmitKey
allowEmptySubmitboolean
clearOnSubmitboolean
variantControlVariant
toneTone
sizeSize
translationsPartial<PromptInputTranslations>
onValueChange(details: PromptInputValueChangeDetails) => void
onSubmit(details: PromptInputSubmitDetails) => void
onStop() => void

Events ​

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

EventPayload
value-changePromptInputValueChangeDetails
submitPromptInputSubmitDetails
stop``

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhPromptInputRootdefaultPromptInputRootSlotProps

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
XhPromptInputRootchildrenSlotChildren<PromptInputRootSlotProps>

State ​

Public state is written to data-state.

PartValues
input'empty' | 'editing' | 'disabled'

The following names are internal to the state machine.

States: empty · editing · disabled

Events: VALUE.SET · COMPOSITION.START · COMPOSITION.END · KEY.SUBMIT · SUBMIT · STOP · CONTROLLED.DISABLE · CONTROLLED.ENABLE · CONTROLLED.VALUE.EMPTY · PRESS.START · PRESS.END · CONTROLLED.VALUE.FILLED

Guards: canSubmit · isLoading · isValueEmpty · isNextValueEmpty · canPress

connect API ​

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

MemberType
valuestring
isComposingboolean
canSubmitboolean
loadingboolean
disabledboolean
setValue(next: string) => void
submit() => void
stop() => void
getRootProps() => T['element']
getControlProps() => T['element']
getInputProps() => T['textarea']
getSubmitTriggerProps() => T['button']

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
Enterprompt-input.kbd.enter
Shift+Enterprompt-input.kbd.shift-enter
Control+Enter / Meta+Enterprompt-input.kbd.mod-enter
Enter / Control+Enter / Meta+Enterprompt-input.kbd.none
Enterprompt-input.kbd.ime-enter
Enterprompt-input.kbd.yield
Enter / Spaceprompt-input.kbd.submit-press
Enter / Spaceprompt-input.kbd.press
Escapeprompt-input.kbd.escape

ARIA ​

These attributes are produced by connect.

PartAttributeValue
inputaria-labeltranslations.input
submit-triggeraria-labeltranslations.stop | translations.send

Style reference ​

Skin ​

@xihan-ui/styles/prompt-input.css is written against [data-scope="prompt-input"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-prompt-input 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-loading'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-toneprops.tone
rootdata-variantprops.variant
rootdata-xh-field-chrome''
rootdata-xh-field-sizeprops.size
inputdata-state'empty' | 'editing' | 'disabled'
inputdata-xh-field-input''
submit-triggerdata-disabled'' (present only while the condition holds)
submit-triggerdata-instant'' (present only while the condition holds)
submit-triggerdata-mode'stop' | 'send'
submit-triggerdata-pressed'' (present only while the condition holds)
submit-triggerdata-xh-action-control''
submit-triggerdata-xh-action-display'always'
submit-triggerdata-xh-action-profile'text'
submit-triggerdata-xh-action-sizeprops.size
submit-triggerdata-xh-action-variant'subtle' | 'solid'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-prompt-input-bgrootbackground-colorxh-field-chrome--xh-_field-variant-bg-rest
--xh-prompt-input-bg-disabledrootbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabled
--xh-prompt-input-bg-hoverrootbackground-colordisabled
hover
invalid
loading
not(:focus-within)
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-bg-hover
--xh-prompt-input-borderrootborderxh-field-chrome--xh-_field-variant-border-rest
--xh-prompt-input-border-focusrootborder-color
box-shadow
disabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focus
--xh-prompt-input-border-hoverrootborder-colordisabled
hover
invalid
loading
not(:focus-within)
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-border-hover
--xh-prompt-input-gaprootgapxh-field-chrome--xh-_prompt-input-gap
--xh-prompt-input-icon-sizeroot--xh-icon-sizedefault
size=lg
size=md
size=sm
xh-field-chrome
--xh-_field-size-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-prompt-input-input-autofill-bginputbox-shadow-webkit-autofill
autofill
xh-field-input
--xh-bg-canvas
--xh-prompt-input-input-autofill-fginput-webkit-text-fill-color-webkit-autofill
autofill
xh-field-input
--xh-fg-default
--xh-prompt-input-input-fginputcolorxh-field-input--xh-fg-default
--xh-prompt-input-input-font-sizeinputfont-size
padding-block
default
xh-field-input
--xh-_prompt-input-font-size
--xh-prompt-input-input-radiusinputborder-radiusdefault--xh-shape-inset
--xh-prompt-input-max-hinputmax-block-sizedefault--xh-leading-normal
--xh-prompt-input-proot--xh-prompt-input-computed-px
padding
padding-inline
default
xh-field-chrome
--xh-_prompt-input-px
--xh-prompt-input-placeholder-fginputcolorplaceholder
xh-field-input
--xh-fg-subtle
--xh-prompt-input-radiusrootborder-radiusxh-field-chrome--xh-shape-surface
--xh-prompt-input-row-gapcontrolgapdefault--xh-_prompt-input-gap
--xh-prompt-input-send-bgsubmit-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-prompt-input-send-bg-activesubmit-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-prompt-input-send-bg-hoversubmit-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-prompt-input-send-bg-offsubmit-trigger--xh-ink-surface
background-color
disabled
xh-ink-surface
--xh-bg-muted
--xh-prompt-input-send-fgsubmit-triggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-prompt-input-shadowrootbox-shadowxh-field-chromenone
--xh-prompt-input-stop-bgsubmit-trigger--xh-ink-surface
background-color
mode=stop
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-prompt-input-stop-bg-activesubmit-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
mode=stop
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-prompt-input-stop-bg-hoversubmit-triggerbackground-colordisabled
hover
loading
mode=stop
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-prompt-input-stop-fgsubmit-triggercolordisabled
hover
is(:active, [data-pressed])
loading
mode=stop
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-prompt-input-stop-mark-radiussubmit-triggerborder-radiusempty
mode=stop
--xh-shape-inset
--xh-prompt-input-stop-mark-sizesubmit-triggerblock-size
inline-size
empty
mode=stop
--xh-icon-size
--xh-prompt-input-submit-font-sizesubmit-triggerfont-sizedefault--xh-text-label-size
--xh-prompt-input-submit-font-weightsubmit-triggerfont-weightdefault--xh-text-label-weight
--xh-prompt-input-submit-pxsubmit-triggerpadding-inlinedefault--xh-_prompt-input-submit-px
--xh-prompt-input-submit-radiussubmit-triggerborder-radiusdefault--xh-shape-control
--xh-prompt-input-submit-shadowsubmit-triggerbox-shadowdefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_highlight-tone

Released under The MIT License