Password Visibility Component

The password visibility component allows users to hide or view the input text when entering a password.

When users enter a password, the password visibility component allows users to toggle between hiding the input text with asterisks (*), or seeing the password in plain text.

Adding a Password Visibility Toggle to a Password Input Field

The password visibility component can be added to any <input> HTML element of type password.

Procedure

  1. Import the PasswordVisibilityToggleModule into the relevant component module, as shown in the following example:
    @NgModule({
      imports: [PasswordVisibilityToggleModule]
    })
    
  2. Insert the cxPasswordVisibilitySwitch directive in an <input> HTML element to bind the password visibility component to the target input, as shown in the following example:
    <input
      type="password"
      cxPasswordVisibilitySwitch
    />
    

Enabling the Password Visibility Toggle

By default, all password inputs in the composable storefront libraries use the password visibility toggle. This feature can be disabled by providing a configuration for the FormConfig, as shown in the following example:

@NgModule({
 providers: [
    provideConfig(<FormConfig>{
      form: {
        passwordVisibilityToggle: false,
      },
    }),
  ],
})

Extending the Password Visibility Toggle

The password visibility component has two states, showState and hideState. You can configure these states using the icon, inputType, and ariaLabel properties of the PasswordInputState interface.