Password Input

A styled and accessible password input component that captures sensitive user credentials with masked text display.

import {PasswordInputModule} from "@qualcomm-ui/angular/password-input"

Examples

Simple

The simple API bundles all subcomponents together into a single component.

Optional hint
<q-password-input
  class="w-72"
  clearable
  hint="Optional hint"
  label="Password"
  placeholder="Create password"
/>

Start Icon

Add a startIcon using the prop at the root. Unlike the Text Input, the endIcon is not supported because its slot is reserved for the password visibility trigger.

<q-password-input
  class="w-72"
  label="Password"
  placeholder="Placeholder text"
  startIcon="KeyRound"
/>

Child Directives

Provide child directives to customize specific elements while keeping the simple API's default structure.

Password
Optional hint
<q-password-input class="w-72" clearable placeholder="Create password">
  <div q-password-input-label>Password</div>
  <div q-password-input-hint>Optional hint</div>
</q-password-input>

Composite

Build with the composite API for granular control. This API requires you to provide each subcomponent, but gives you full control over the structure and layout.

Optional hint
<div class="w-72" q-password-input-root>
  <label q-password-input-label>Label</label>
  <div q-password-input-input-group>
    <input placeholder="Placeholder text" q-password-input-input />
    <button q-password-input-clear-trigger></button>
    <button q-password-input-visibility-trigger></button>
    <span q-password-input-error-indicator></span>
  </div>
  <div q-password-input-error-text>Error text</div>
  <div q-password-input-hint>Optional hint</div>
</div>

Controlled Visibility

Set the initial visibility using the defaultVisible prop, or use visible and visibleChanged to control the visibility manually. These props follow our controlled state pattern.

import {Component, signal} from "@angular/core"

import {ButtonModule} from "@qualcomm-ui/angular/button"
import {PasswordInputModule} from "@qualcomm-ui/angular/password-input"

@Component({
  imports: [PasswordInputModule, ButtonModule],
  selector: "password-input-controlled-visibility-demo",
  template: `
    <div class="flex flex-col gap-4">
      <q-password-input
        class="w-72"
        defaultValue="passw0rd"
        label="Password"
        placeholder="Enter your password"
        [visible]="visible()"
        (visibleChanged)="setVisible($event)"
      />

      <button
        emphasis="primary"
        q-button
        variant="outline"
        (click)="toggleVisible()"
      >
        {{ visible() ? "Hide Password" : "Show Password" }}
      </button>
    </div>
  `,
})
export class PasswordInputControlledVisibilityDemo {
  protected readonly visible = signal(false)

  setVisible(visible: boolean) {
    this.visible.set(visible)
  }

  toggleVisible() {
    this.visible.update((visible) => !visible)
  }
}

Error Text and Indicator

Provide a custom error message using the errorText prop.

For template-driven forms, the error text and indicator will only render when invalid is true.

You must enter your password
<q-password-input
  #passwordInput
  class="w-64"
  errorText="You must enter your password"
  label="Label"
  placeholder="Enter your password"
  required
  [invalid]="!value()"
  [(ngModel)]="value"
/>

Forms

Control and validate the input value using Angular form control bindings.

Template Forms

When using template-driven forms with ngModel, perform validation manually in your component and pass the result to the invalid property.

TIP

Form validation timing is controlled by the updateOn property on the form control.

<q-password-input
  class="w-72"
  label="Required"
  placeholder="Enter a value"
  [errorText]="errorText()"
  [invalid]="!!errorText()"
  [(ngModel)]="value"
/>

Required

When using template forms, pass the required property to apply the RequiredValidator to the form control.

<q-password-input
  class="w-72"
  label="Required"
  placeholder="Enter a value"
  required
  [(ngModel)]="value"
/>

Reactive Forms

Use Reactive Forms for better control of form state and validation.

  • We provide default error messages for every built-in validator, so you can omit the errorText prop when using Reactive Forms.
  • We also look for the error and errorText properties on custom validators. If you provide a custom validator, use one of these properties to provide error messages automatically when the field is invalid:
must be 8+ characters with at least 1 number, lowercase, uppercase, and special character.

State Guidelines

The disabled, invalid, and required properties have no effect when using Reactive Forms. Use the equivalent Reactive Form bindings instead:

This field is required
disabledField = new FormControl("")
invalidField = new FormControl("", {
  validators: [Validators.required],
})
requiredField = new FormControl("", {validators: [Validators.required]})

API

<q-password-input>

The <q-password-input> component extends the q-password-input-root directive with the following properties:

PropTypeDefault
When true, renders a clear button that resets the input value on click. The button only appears when the input has a value.
boolean
true
Optional error that describes the element when invalid is true.
string
Optional hint describing the element. This element is automatically associated with the component's input element for accessibility.
string
Optional label describing the element. Recommended. This element is automatically associated with the component's input element for accessibility.
string
HTML placeholder attribute, passed to the internal input element.
string
Type
boolean
Description
When true, renders a clear button that resets the input value on click. The button only appears when the input has a value.
Type
string
Description
Optional error that describes the element when invalid is true.
Type
string
Description
Optional hint describing the element. This element is automatically associated with the component's input element for accessibility.
Type
string
Description
Optional label describing the element. Recommended. This element is automatically associated with the component's input element for accessibility.
Type
string
Description
HTML placeholder attribute, passed to the internal input element.

Composite API

q-password-input-root

PropTypeDefault
The autocomplete attribute for the password input.
| 'current-password'
| 'new-password'
"current-password"
The initial state of the input when rendered. Use when you don't need to control the checked state of the input. This property will be ignored if you opt into controlled state via form control bindings.
string
The default visibility of the password input.
boolean
The document's text/writing direction.
'ltr' | 'rtl'
"ltr"
Controls whether the input is disabled in template-driven forms. When true, prevents user interaction and applies visual styling to indicate the disabled state.
boolean
A root node to correctly resolve the Document in custom environments. i.e., Iframes, Electron.
() =>
| Node
| ShadowRoot
| Document
Controls the visual error state of the input. When true, applies semantic error styling to indicate validation failure.
boolean
The name of the input field. Useful for form submission.
string
Whether the input is read-only. When true, prevents user interaction while keeping the input focusable and visible.
boolean
Controls whether the input is required in template-driven forms. When true, the input must have a value for form validation to pass.
boolean
The size of the input field and its elements. Governs properties like font size, item padding, and icon sizes.
| 'sm'
| 'md'
| 'lg'
'md'
lucide-angular icon, positioned at the start of the input field.
| string
| LucideIconData
Localized messages to use for element labels.
{
visibilityTrigger?: (
visible: boolean,
) => string
}
Whether the password input is visible.
boolean
Event emitted when the input value changes. This is only emitted on interaction. It doesn't emit in response to programmatic form control changes.
string
Function called when the visibility changes.
boolean
Type
| 'current-password'
| 'new-password'
Description
The autocomplete attribute for the password input.
Type
string
Description
The initial state of the input when rendered. Use when you don't need to control the checked state of the input. This property will be ignored if you opt into controlled state via form control bindings.
Type
boolean
Description
The default visibility of the password input.
Type
'ltr' | 'rtl'
Description
The document's text/writing direction.
Type
boolean
Description
Controls whether the input is disabled in template-driven forms. When true, prevents user interaction and applies visual styling to indicate the disabled state.
Type
() =>
| Node
| ShadowRoot
| Document
Description
A root node to correctly resolve the Document in custom environments. i.e., Iframes, Electron.
Type
boolean
Description
Controls the visual error state of the input. When true, applies semantic error styling to indicate validation failure.
Type
string
Description
The name of the input field. Useful for form submission.
Type
boolean
Description
Whether the input is read-only. When true, prevents user interaction while keeping the input focusable and visible.
Type
boolean
Description
Controls whether the input is required in template-driven forms. When true, the input must have a value for form validation to pass.
Type
| 'sm'
| 'md'
| 'lg'
Description
The size of the input field and its elements. Governs properties like font size, item padding, and icon sizes.
Type
| string
| LucideIconData
Description
lucide-angular icon, positioned at the start of the input field.
Type
{
visibilityTrigger?: (
visible: boolean,
) => string
}
Description
Localized messages to use for element labels.
Type
boolean
Description
Whether the password input is visible.
Type
string
Description
Event emitted when the input value changes. This is only emitted on interaction. It doesn't emit in response to programmatic form control changes.
Type
boolean
Description
Function called when the visibility changes.

q-password-input-input-group

q-password-input-label

PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.

q-password-input-hint

PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.

q-password-input-clear-trigger

q-password-input-input

PropType
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.

q-password-input-error-text

PropType
Optional error indicator icon.
| string
| LucideIconData
id attribute. If omitted, a unique identifier will be generated for accessibility.
string
Type
| string
| LucideIconData
Description
Optional error indicator icon.
Type
string
Description
id attribute. If omitted, a unique identifier will be generated for accessibility.

q-password-input-error-indicator

PropTypeDefault
lucide-angular icon
| LucideIconData
| string
CircleAlert
Type
| LucideIconData
| string
Description
lucide-angular icon