Password Group
A password input in its box, with a button to show or hide the password — the caret stays in the input — and one to generate a strong one, on your Signal Form. In a scField, as any input: its label and descriptions. A warning while Caps Lock is on, a strength meter, the rules met or not: each a part to add.
Usage
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScFieldDescription, ScLabel, ScPasswordGroup, ScPasswordInput, ScPasswordToggle,} from '@semantic-components/ui';import { SiEyeIcon, SiEyeOffIcon } from '@semantic-icons/lucide-icons';
@Component({ selector: 'app-password-group-usage-demo', imports: [ FormField, ScFieldDescription, ScLabel, ScField, ScPasswordGroup, ScPasswordInput, ScPasswordToggle, SiEyeIcon, SiEyeOffIcon, ], template: ` <div scField class="w-full max-w-sm"> <label scLabel>Password</label> <div scPasswordGroup #password="scPasswordGroup"> <input scPasswordInput [formField]="login.password" /> <button scPasswordToggle> @if (password.visible()) { <svg siEyeOffIcon></svg> <span class="sr-only">Hide password</span> } @else { <svg siEyeIcon></svg> <span class="sr-only">Show password</span> } </button> </div> <p scFieldDescription>The one you signed up with.</p> </div> `, host: { class: 'flex w-full flex-col items-center gap-4' }, encapsulation: ViewEncapsulation.None,})export class PasswordGroupUsageDemo { private readonly login = form(signal({ password: '' }));}Anatomy
A scField holds the label, the group (the input and its buttons) and the descriptions. The group holds the state (the password shown or not); a generate button goes in it, beside the toggle. A Caps Lock warning, a strength meter and the rules are parts you add to the field.
import { ScField, ScLabel, ScPasswordGroup, ScPasswordInput, ScPasswordToggle, ScPasswordCapsLock, ScPasswordStrength, ScPasswordStrengthLabel, ScPasswordRequirements, ScPasswordRequirement, ScPasswordGenerate,} from '@semantic-components/ui';<div scField> <label scLabel>…</label> <div scPasswordGroup #password="scPasswordGroup"> <input scPasswordInput [formField]="…" /> <button scPasswordGenerate>…</button> <button scPasswordToggle>…</button> </div> <p scPasswordCapsLock>…</p> <div scPasswordStrength [score]="…" aria-label="…"> <span scPasswordStrengthLabel>…</span> </div> <ul scPasswordRequirements> <li scPasswordRequirement [met]="…">…</li> </ul></div>Examples
Shown
Shown: true
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScLabel, ScPasswordGroup, ScPasswordInput, ScPasswordToggle,} from '@semantic-components/ui';import { SiEyeIcon, SiEyeOffIcon } from '@semantic-icons/lucide-icons';Disabled
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, disabled, form } from '@angular/forms/signals';import { ScField, ScLabel, ScPasswordGroup, ScPasswordInput, ScPasswordToggle,} from '@semantic-components/ui';import { SiEyeIcon, SiEyeOffIcon } from '@semantic-icons/lucide-icons';Signal Forms
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, FormRoot, form, minLength, required,} from '@angular/forms/signals';import { ScButton,Caps Lock
import { Component, ViewEncapsulation, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScLabel, ScPasswordCapsLock, ScPasswordGroup, ScPasswordInput, ScPasswordToggle,} from '@semantic-components/ui';Strength
import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScLabel, ScPasswordGroup, ScPasswordInput, ScPasswordStrength, ScPasswordStrengthLabel, ScPasswordToggle,Requirements
- At least 12 characters (not met)
- A number (not met)
- Upper and lower case (not met)
- A symbol (not met)
import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScLabel, ScPasswordGroup, ScPasswordInput, ScPasswordRequirement, ScPasswordRequirements, ScPasswordToggle,Generate
import { Component, ViewEncapsulation, computed, signal } from '@angular/core';import { FormField, form } from '@angular/forms/signals';import { ScField, ScLabel, ScPasswordGenerate, ScPasswordGroup, ScPasswordInput, ScPasswordStrength, ScPasswordStrengthLabel,RTL
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation, computed, signal,} from '@angular/core';import { FormField, form } from '@angular/forms/signals';import {API reference
Each part takes class, merged over its own (cn: a later class wins). The label, descriptions and errors are the scField's it is in, as for any input.
| Part | Selector | Description |
|---|---|---|
ScPasswordGroup | div[scPasswordGroup] | The box round the input and its buttons: one border, one focus ring. Holds [(visible)] (the password shown or not). exportAs scPasswordGroup: visible(), toggle(). |
ScPasswordInput | input[scPasswordInput] | The password: hidden, or text while visible; never spellchecked, capitalised or corrected. autocomplete ('current-password', 'new-password', 'off'), ignorePasswordManagers; its state from your Signal Form ([formField]). |
ScPasswordToggle | button[scPasswordToggle] | Shows or hides the password; a click leaves the caret in the input. Its icon and name follow the state (Show / Hide password) — not aria-pressed. variant ('ghost'), size ('icon-sm'). |
ScPasswordCapsLock | [scPasswordCapsLock] | Your warning, shown while Caps Lock is on and the field’s input has the focus — anywhere in the scField; a polite live region. |
ScPasswordStrength, ScPasswordStrengthLabel | div[scPasswordStrength], [scPasswordStrengthLabel] | score (0–4) as four segments, a meter: name it; the label is its value in your words (aria-valuetext). |
ScPasswordRequirements, ScPasswordRequirement | ul[scPasswordRequirements], li[scPasswordRequirement] | Your rules, in the scField: read with its input (aria-describedby); each met or not (met, data-met), the state in words for screen readers. |
ScPasswordGenerate | button[scPasswordGenerate] | Fills the input with a strong password from the browser's secure randomness: length (16); lower, upper, digits, symbols (each on); look-alikes left out — and shows it. In the group, beside the toggle: variant ('ghost'), size ('icon-sm'); your icon and its name. |