Password displays strength indicator for password fields.

import { PasswordModule } from 'primeng/password';

Two-way value binding is defined using ngModel.

<p-password [(ngModel)]="value" [feedback]="false" />

Password can also be used with reactive forms. In this case, the formControlName property is used to bind the component to a form control.

<form [formGroup]="formGroup">
    <p-password formControlName="value" [feedback]="false" />

Strength meter is displayed as a popup while a value is being entered.

<p-password [(ngModel)]="value" />

Labels are translated at component level by promptLabel, weakLabel, mediumLabel and strongLabel properties. In order to apply global translations for all Password components in the application, refer to the locale

    promptLabel="Choose a password"
    weakLabel="Too simple" 
    mediumLabel="Average complexity" 
    strongLabel="Complex password" />

When toggleMask is present, an icon is displayed to show the value as plain text.

<p-password [(ngModel)]="value" [toggleMask]="true" />

3 templates are included to customize the overlay. These are header, content and footer. Note that content overrides the default meter.

<p-password [(ngModel)]="value">
    <ng-template pTemplate="header">
        <h6>Pick a password</h6>
    <ng-template pTemplate="footer">
        <p-divider />
        <p class="mt-2">Suggestions</p>
        <ul class="pl-2 ml-2 mt-0" style="line-height: 1.5">
            <li>At least one lowercase</li>
            <li>At least one uppercase</li>
            <li>At least one numeric</li>
            <li>Minimum 8 characters</li>

A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information.

    <p-password [(ngModel)]="value" [feedback]="false" />
    <label for="password">Password</label>

Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.

    variant="filled" />

Invalid state style is added using the ng-invalid and ng-dirty class to indicate a failed validation.

<p-password [(ngModel)]="value" class="ng-invalid ng-dirty" />

When disabled is present, the element cannot be edited and focused.

    placeholder="Disabled" />

Following is the list of structural style classes, for theming classes visit theming page.

p-password-panelContainer of password panel
p-password-meterMeter element of password strength
p-password-infoText to display strength

Screen Reader

Value to describe the component can either be provided via label tag combined with id prop or using ariaLabelledBy, ariaLabel props. Screen reader is notified about the changes to the strength of the password using a section that has aria-live while typing.

<label for="pwd1">Password</label>
<p-password inputId="pwd1" />

<span id="pwd2">Password</span>
<p-password ariaLabelledBy="pwd2" />

<p-password ariaLabel="Password" />

Keyboard Support

tabMoves focus to the input.
escapeHides the strength meter if open.