Skip to content

InputPassword

Use InputPassword to let shoppers enter a password. It adds a show/hide toggle, an optional error message, and a password-strength status indicator built on the Input and Field components.

The SDK InputPassword showing a password field with a show and hide toggle.
import { InputPassword } from '/@dropins/tools/components.js';
PropTypeReq?Description
namestringNoThe field name, used for form data. Defaults to ‘password’.
placeholderstringNoPlaceholder text. Defaults to ‘Password’.
floatingLabelstringNoLabel text that floats above the field. Defaults to ‘Password’.
defaultValuestringNoThe initial value of the password field.
requiredbooleanNoMark the field as mandatory.
errorMessagestring | undefinedNoA custom error message to display below the field.
autoCompletestringNoEnables browser autocomplete.
hideStatusIndicatorbooleanNoHide the password-strength status indicator. Defaults to false.
onValue(value: any) => voidNoCalled with the trimmed value when it changes (debounced).
onBlur(event: Event) => voidNoCalled when the field loses focus.

InputPassword also accepts the PasswordStatusIndicator props that configure the strength indicator: minLength and requiredCharacterClasses set which requirements the indicator shows (the length row appears when minLength is greater than 0; the character-classes row appears when requiredCharacterClasses is 2 or more), while validateLengthConfig and uniqueSymbolsStatus set each requirement’s status. It renders as a <div> and accepts standard HTML attributes such as id and className.

Render a required password field with a strength indicator.

import { InputPassword, provider } from '/@dropins/tools/components.js';
await provider.render(InputPassword, {
name: 'password',
required: true,
minLength: 8,
requiredCharacterClasses: 2,
onValue: (value) => yourSavePassword(value),
})(document.querySelector('.password-input'));
  • Input — the text input this component builds on.
  • Field — wraps a control with a label and error message.