Skip to main content
cngx-src documentation

CngxPasswordToggle

DirectivePrimaryv0.1.0WCAG AA

projects/forms/input/password-toggle.directive.ts

Import#

import { CngxPasswordToggle } from '@cngx/forms/input'

Description#

Toggles a password input between type="password" and type="text".

Place on the same <input> element (works with or without cngxInput). Exposes a visible signal and toggle() method for binding a toggle button.

<input cngxInput cngxPasswordToggle #pwd="cngxPasswordToggle" type="password" />
<button type="button" (click)="pwd.toggle()" [attr.aria-label]="pwd.visible() ? 'Hide password' : 'Show password'">
  {{ pwd.visible() ? 'Hide' : 'Show' }}
</button>

https://cngxjs.github.io/cngx/examples/#/forms/input/character-counter https://cngxjs.github.io/cngx/examples/#/forms/input/password-visibility-toggle https://cngxjs.github.io/cngx/examples/#/forms/input/smart-autocomplete-and-spellcheck

Metadata#

Host#

Index#

Instance Properties#

visible#unknown
Readonly

Whether the password is currently visible (type="text").

this.visibleState.asReadonly()

Methods#

hide#void

Hide password.

show#void

Show password.

toggle#void

Toggle password visibility.

HostBindings#

BindingExpression
[attr.type]inputType()
[attr.spellcheck]"false"
[attr.autocomplete]autocomplete()