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

查看生态总览
Skip to content

PinInput ​

Data entry 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="pin-input": root · label · group · input · separator · hidden-input

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-pin-input>
Vue componentsXhPinInputGroup XhPinInputHiddenInput XhPinInputInput XhPinInputLabel XhPinInputRoot XhPinInputSeparator
ComposableusePinInput
State machinepinInputMachine
Skin@xihan-ui/styles/pin-input.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
valuestring[]
defaultValuestring[]
lengthnumber
typePinInputType
patternstring
maskboolean
otpboolean
placeholderstring
disabledboolean
readOnlyboolean
requiredboolean
invalidboolean
blurOnCompleteboolean
namestring
variantControlVariant
toneTone
sizeSize
translationsPartial<PinInputTranslations>
onValueChange(details: PinInputValueChangeDetails) => void
onValueComplete(details: PinInputValueChangeDetails) => void

Events ​

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

EventPayload
value-changePinInputValueChangeDetails
value-completePinInputValueChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhPinInputRootdefaultPinInputRootSlotProps
XhPinInputRootlabel—

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
XhPinInputInputindexnumber | stringYes
XhPinInputRootlabelReactNode
XhPinInputRootchildrenSlotChildren<PinInputRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · VALUE.FILL · VALUE.CLEAR_AT · VALUE.CLEAR · INPUT.FOCUS · INPUT.BLUR · FORM.RESET

Guards: canEdit

connect API ​

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

MemberType
valuestring[]
valueAsStringstring
completeboolean
lengthnumber
focusedIndexnumber
disabledboolean
readOnlyboolean
invalidboolean
setValue(next: string[]) => void
clear() => void
getRootProps() => T['element']
getLabelProps() => T['label']
getGroupProps() => T['element']
getInputProps(props: PinInputInputProps) => T['input']
getSeparatorProps() => T['element']
getHiddenInputProps() => T['input']

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
ArrowRightpin-input.kbd.next
ArrowLeftpin-input.kbd.prev
Homepin-input.kbd.first
Endpin-input.kbd.last
Backspacepin-input.kbd.backspace
Deletepin-input.kbd.delete

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-labelprops.ariaLabel
rootaria-labelledbyid of the label part | undefined
rootrole'group'
inputaria-invalid'true' | 'false'
inputaria-labellabel.input(index + 1, length)
separatoraria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/pin-input.css is written against [data-scope="pin-input"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-pin-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-complete'' (present only while the condition holds)
rootdata-disabled'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-toneprops.tone
rootdata-variantprops.variant
labeldata-disabled'' (present only while the condition holds)
groupdata-disabled'' (present only while the condition holds)
groupdata-invalid'' (present only while the condition holds)
inputdata-disabled'' (present only while the condition holds)
inputdata-empty'' (present only while the condition holds)
inputdata-focus'' (present only while the condition holds)
inputdata-indexString(index)
inputdata-invalid'' (present only while the condition holds)
inputdata-readonly'' (present only while the condition holds)
inputdata-variantprops.variant
inputdata-xh-field-chrome''
inputdata-xh-field-sizeprops.size
separatordata-disabled'' (present only while the condition holds)

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-pin-input-box-autofill-bginputbox-shadow-webkit-autofill
autofill
--xh-bg-canvas
--xh-pin-input-box-autofill-fginput-webkit-text-fill-color-webkit-autofill
autofill
--xh-fg-default
--xh-pin-input-box-bginputbackground-colorxh-field-chrome--xh-_field-variant-bg-rest
--xh-pin-input-box-bg-disabledinputbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabled
--xh-pin-input-box-bg-hoverinputbackground-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-pin-input-box-bg-readonlyinputbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-only
--xh-pin-input-box-borderinputborderxh-field-chrome--xh-_field-variant-border-rest
--xh-pin-input-box-border-completeinput
root
border-colorcomplete
invalid
not([data-invalid], :disabled)
--xh-_pin-input-accent
--xh-pin-input-box-border-focusinputborder-color
box-shadow
disabled
focus
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focus
--xh-pin-input-box-border-hoverinputborder-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-pin-input-box-border-invalidinputborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalid
--xh-pin-input-box-fginputcolorxh-field-chrome--xh-fg-default
--xh-pin-input-box-font-sizeinputfont-sizedefault--xh-_pin-input-box-font-size
--xh-pin-input-box-gapinputmargin-inline-startdefault--xh-_pin-input-box-gap
--xh-pin-input-box-radiusinputborder-radiusxh-field-chrome--xh-shape-control
--xh-pin-input-box-shadowinputbox-shadowxh-field-chromenone
--xh-pin-input-box-sizeinputblock-size
inline-size
min-block-size
default
has([data-xh-field-input][data-xh-field-layout='multi-tag'])
has([data-xh-field-input][data-xh-field-layout='single-line'])
has([data-xh-field-input][data-xh-field-layout='textarea'])
xh-field-chrome
xh-field-input
xh-field-layout=multi-tag
xh-field-layout=single-line
xh-field-layout=textarea
--xh-_pin-input-box-size
--xh-pin-input-gaplabel
root
gap
margin-block-end
default--xh-space-1
--xh-pin-input-label-fglabelcolordefault--xh-fg-muted
--xh-pin-input-label-fg-disabledlabelcolordisabled--xh-fg-muted
--xh-pin-input-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-pin-input-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-pin-input-label-gaplabelmargin-block-enddefault--xh-space-2
--xh-pin-input-placeholder-fginputcolorplaceholder--xh-fg-subtle
--xh-pin-input-separator-fgseparatorcolordefault--xh-fg-muted
--xh-pin-input-separator-fg-disabledseparatorcolordisabled--xh-fg-disabled
--xh-pin-input-separator-font-sizeseparatorfont-sizedefault--xh-_pin-input-box-font-size
--xh-pin-input-separator-gapseparatormargin-inlinedefault--xh-_pin-input-box-gap

Released under The MIT License