Skip to main content

Password Input

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The PasswordInput component provides a secure password input field with visibility toggle and optional strength meter. Built with security and usability in mind, it includes password strength validation, customizable labels, and accessibility features.

Basic Usage

Password strength:Very weak

Without Strength Meter

Custom Labels

Força da senha:Muito fraca

Form Integration

Password strength:Very weak

Password Strength Examples

Very Weak Password

Password strength:Very weak

Weak Password

Password strength:Very weak

Medium Password

Password strength:Very weak

Strong Password

Password strength:Very weak

Login Form

Forgot password?

Disabled State

Password strength:Very weak

Properties

PasswordInput

PropertyTypeDefaultDescription
showStrengthMeterbooleantrueWhether to show the password strength meter.
strengthLabelsobjectSee belowCustom labels for strength levels.
showPasswordLabelstring"Show password"Label for show password button.
hidePasswordLabelstring"Hide password"Label for hide password button.
strengthTitlestring"Password strength"Title for the strength meter section.
classNamestring-Additional CSS classes for the input.
placeholderstring-Placeholder text for the input.
valuestring-Controlled value of the input.
defaultValuestring-Default value for uncontrolled input.
onChange(event: ChangeEvent<HTMLInputElement>) => void-Change event handler.
disabledbooleanfalseWhether the input is disabled.
requiredbooleanfalseWhether the input is required.
idstring-HTML id attribute.
namestring-HTML name attribute.

Default Strength Labels

{
veryWeak: 'Very weak',
weak: 'Weak',
medium: 'Medium',
strong: 'Strong',
veryStrong: 'Very strong'
}

Password Strength Calculation

The component calculates password strength based on:

CriteriaPointsDescription
Length25 pointsPassword has 8 or more characters
Lowercase25 pointsContains lowercase letters (a-z)
Uppercase25 pointsContains uppercase letters (A-Z)
Numbers25 pointsContains numeric digits (0-9)

Strength Levels

ScoreLevelColor
0 pointsVery WeakRed
1-25 pointsWeakOrange
26-50 pointsMediumYellow
51-75 pointsStrongLight Green
76-100 pointsVery StrongGreen

Accessibility

The PasswordInput component includes comprehensive accessibility features:

  • Keyboard Navigation - Full keyboard support for all interactions
  • Screen Reader Support - Proper labeling and ARIA attributes for toggle button
  • Focus Management - Clear focus indicators and logical tab order
  • Password Visibility - Toggle button with descriptive labels
  • Form Integration - Works seamlessly with form validation
  • Strength Feedback - Visual and textual feedback for password strength

Security Considerations

  1. Client-side Only - Strength calculation is for UX, not security validation
  2. Server Validation - Always validate password strength on the server
  3. No Storage - Component doesn't store or transmit passwords
  4. Visibility Toggle - Helps users verify their input while maintaining security
  5. Progressive Enhancement - Works without JavaScript for basic functionality

Common Use Cases

The PasswordInput component is perfect for:

  • User Registration - Account creation with password strength guidance
  • Login Forms - Secure authentication with visibility toggle
  • Password Reset - New password creation with strength validation
  • Settings Pages - Password change functionality
  • Admin Panels - User management and password policies
  • Multi-step Forms - Registration flows with password requirements

Best Practices

  1. Clear Requirements - Communicate password requirements upfront
  2. Real-time Feedback - Show strength as users type
  3. Appropriate Labels - Use clear, descriptive labels for all elements
  4. Server Validation - Never rely solely on client-side validation
  5. Accessibility - Ensure all users can interact with the component
  6. Mobile Optimization - Test on various devices and screen sizes
  7. Security Guidelines - Follow current password security best practices
  8. Localization - Provide appropriate labels for different languages