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

查看生态总览
Skip to content

PasswordInput ​

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="password-input": root · label · control · input · visibility-trigger · caps-lock-indicator · strength-meter

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-password-input>
Vue componentsXhPasswordInputCapsLockIndicator XhPasswordInputControl XhPasswordInputInput XhPasswordInputLabel XhPasswordInputRoot XhPasswordInputStrengthMeter XhPasswordInputVisibilityTrigger
ComposableusePasswordInput
State machinepasswordInputMachine
Skin@xihan-ui/styles/password-input.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
valuestring
defaultValuestring
revealedboolean
defaultRevealedboolean
disabledboolean
readOnlyboolean
requiredboolean
invalidboolean
namestring
placeholderstring
autoCompletestring
strengthnumber
translationsPartial<PasswordInputTranslations>
variantControlVariant
toneTone
sizeSize
onValueChange(details: PasswordInputValueChangeDetails) => void
onRevealedChange(details: PasswordInputRevealedChangeDetails) => void

Events ​

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

EventPayload
value-changePasswordInputValueChangeDetails
revealed-changePasswordInputRevealedChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhPasswordInputRootdefaultPasswordInputRootSlotProps
XhPasswordInputRootlabel—

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
XhPasswordInputRootlabelReactNode
XhPasswordInputRootchildrenSlotChildren<PasswordInputRootSlotProps>

State ​

Public state is written to data-state.

PartValues
visibility-trigger'visible' | 'hidden'
caps-lock-indicator'visible' | 'hidden'

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · REVEALED.SET · REVEALED.TOGGLE · CAPS_LOCK.SET · FORM.RESET · PRESS.START · PRESS.END

Guards: canEdit · canReveal

connect API ​

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

MemberType
valuestring
emptyboolean
revealedboolean
capsLockboolean
disabledboolean
readOnlyboolean
invalidboolean
inputTypePasswordInputType
capsLockMessagestring
strengthnumber | undefined
setValue(next: string) => void
setRevealed(next: boolean) => void
toggleRevealed() => void
getRootProps() => T['element']
getLabelProps() => T['label']
getControlProps() => T['element']
getInputProps() => T['input']
getVisibilityTriggerProps() => T['button']
getCapsLockIndicatorProps() => T['element']
getStrengthMeterProps() => 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 / Spacepassword-input.kbd.toggle
CapsLockpassword-input.kbd.caps-lock
Enter / Spacepassword-input.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
inputaria-describedbyid of the capsLock part | undefined
inputaria-invalid'true' | 'false'
inputaria-labelprops.ariaLabel
inputaria-labelledbyid of the label part | undefined
visibility-triggeraria-controlsid of the password-input-input part
visibility-triggeraria-labellabel.visibilityTriggerHide | label.visibilityTriggerShow
caps-lock-indicatoraria-atomic'true'
caps-lock-indicatoraria-live'polite'
caps-lock-indicatorrole'status'
strength-meteraria-labellabel.strengthMeter
strength-meteraria-valuemax4
strength-meteraria-valuemin0
strength-meteraria-valuenowundefined | Math.min(Math.max(Math.trunc(rawStrength), 0), STRENG…
strength-meterrole'meter'

Style reference ​

Skin ​

@xihan-ui/styles/password-input.css is written against [data-scope="password-input"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-password-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-empty'' (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)
controldata-disabled'' (present only while the condition holds)
controldata-invalid'' (present only while the condition holds)
controldata-readonly'' (present only while the condition holds)
controldata-variantprops.variant
controldata-xh-field-chrome''
controldata-xh-field-sizeprops.size
inputdata-disabled'' (present only while the condition holds)
inputdata-invalid'' (present only while the condition holds)
inputdata-readonly'' (present only while the condition holds)
inputdata-xh-field-input''
inputdata-xh-field-layout'single-line'
visibility-triggerdata-disabled'' (present only while the condition holds)
visibility-triggerdata-pressed'' (present only while the condition holds)
visibility-triggerdata-state'visible' | 'hidden'
visibility-triggerdata-xh-action-control''
visibility-triggerdata-xh-action-display'always'
visibility-triggerdata-xh-action-profile'field-inset'
visibility-triggerdata-xh-action-sizeprops.size
visibility-triggerdata-xh-action-variant'ghost'
caps-lock-indicatordata-state'visible' | 'hidden'
strength-meterdata-disabled'' (present only while the condition holds)
strength-meterdata-levelundefined | String(strength)

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-password-input-caps-lock-fgcaps-lock-indicatorcolordefault--xh-fg-muted
--xh-password-input-caps-lock-fg-disabledcaps-lock-indicator
control
colordisabled--xh-fg-disabled
--xh-password-input-caps-lock-font-sizecaps-lock-indicatorfont-sizedefault--xh-_password-input-caps-lock-font-size
--xh-password-input-control-bgcontrolbackground-colorxh-field-chrome--xh-_field-variant-bg-rest
--xh-password-input-control-bg-disabledcontrolbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabled
--xh-password-input-control-bg-hovercontrolbackground-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-password-input-control-bg-readonlycontrolbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-only
--xh-password-input-control-bordercontrolborderxh-field-chrome--xh-_field-variant-border-rest
--xh-password-input-control-border-focuscontrolborder-color
box-shadow
disabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focus
--xh-password-input-control-border-hovercontrolborder-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-password-input-control-border-invalidcontrolborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalid
--xh-password-input-control-fgcontrolcolorxh-field-chrome--xh-fg-default
--xh-password-input-control-gapcontrolgapxh-field-chrome--xh-_password-input-gap
--xh-password-input-control-hcontrolblock-size
min-block-size
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-_password-input-h
--xh-password-input-control-min-wcontrol
root
min-inline-sizedefault
xh-field-chrome
--xh-control-min-w
--xh-password-input-control-pxcontrolpadding-inlinexh-field-chrome--xh-_password-input-px
--xh-password-input-control-radiuscontrolborder-radiusxh-field-chrome--xh-shape-control
--xh-password-input-control-shadowcontrolbox-shadowxh-field-chromenone
--xh-password-input-control-wrootinline-size
min-inline-size
default--xh-control-w
--xh-password-input-gaplabel
root
gap
margin-block-end
default--xh-space-1
--xh-password-input-icon-sizecontrol
root
--xh-icon-sizedefault
size=lg
size=sm
xh-field-chrome
--xh-_field-size-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-password-input-input-autofill-bginputbox-shadow-webkit-autofill
autofill
xh-field-input
--xh-bg-canvas
--xh-password-input-input-autofill-fginput-webkit-text-fill-color-webkit-autofill
autofill
xh-field-input
--xh-fg-default
--xh-password-input-input-fginputcolorxh-field-input--xh-fg-default
--xh-password-input-input-font-sizeinputfont-sizexh-field-input--xh-_password-input-font-size
--xh-password-input-label-fglabelcolordefault--xh-fg-muted
--xh-password-input-label-fg-disabledlabelcolordisabled--xh-fg-muted
--xh-password-input-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-password-input-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-password-input-label-gaplabelmargin-block-enddefault--xh-space-2
--xh-password-input-placeholder-fginputcolorplaceholder
xh-field-input
--xh-fg-subtle
--xh-password-input-strength-fgstrength-meterbackgroundempty--xh-_password-input-strength-fg
--xh-password-input-strength-radiusstrength-meterborder-radiusdefault--xh-shape-pill
--xh-password-input-strength-thicknessstrength-meterblock-sizedefault--xh-track-thickness
--xh-password-input-strength-trackstrength-meterbackgrounddefault--xh-bg-subtle-active
--xh-password-input-trigger-bgvisibility-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-password-input-trigger-bg-activevisibility-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-password-input-trigger-bg-hovervisibility-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-password-input-trigger-fgvisibility-triggercolordefault--xh-fg-muted
--xh-password-input-trigger-fg-hovervisibility-triggercolordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-fg-default
--xh-password-input-trigger-font-sizevisibility-triggerfont-sizedefault--xh-_password-input-trigger-font-size
--xh-password-input-trigger-radiusvisibility-triggerborder-radiusdefault--xh-shape-inset
--xh-password-input-trigger-sizevisibility-triggerblock-size
inline-size
min-inline-size
default
xh-action-profile=field-inset
--xh-_action-profile-visual-size

Released under The MIT License