Password Input

Forms
Security

Secure password input with visibility toggle, strength indicator, and requirements checklist. Perfect for login and registration forms.

Preview

Click the eye icon to toggle visibility

Click the eye icon to toggle visibility

With Strength Indicator

Visual feedback on password strength

Good

With Requirements Checklist

Live validation against password requirements

Sizes

Three size options: sm, md, and lg

Small

Medium (default)

Large

States

Various input states

Read Only

Disabled

With Error

Password must be at least 8 characters

Custom Requirements

Configure password validation rules

Props

PasswordInput component API reference

PropTypeDefaultDescription
valuestringCurrent password value
onChange(value: string) => voidCallback when value changes
labelstringLabel text
placeholderstringInput placeholder
size'sm' | 'md' | 'lg''md'Input size
showStrengthbooleanfalseDisplay password strength meter
showRequirementsbooleanfalseDisplay requirements checklist
minLengthnumber8Minimum required length
requireUppercasebooleantrueRequire uppercase letters
requireLowercasebooleantrueRequire lowercase letters
requireNumbersbooleantrueRequire numbers
requireSpecialbooleantrueRequire special characters
errorstringError message
helperTextstringHelper text
disabledbooleanfalseDisable interaction
readOnlybooleanfalseMake read-only
autoCompletestring'current-password'Autocomplete attribute

Usage

Import and implementation example

import { PasswordInput } from '@/components/ui/password-input'

export default function Example() {
  const [password, setPassword] = useState('')

  return (
    <>
      {/* Basic password input */}
      <PasswordInput
        label="Password"
        value={password}
        onChange={setPassword}
        placeholder="Enter password"
      />

      {/* With strength indicator */}
      <PasswordInput
        label="New Password"
        value={password}
        onChange={setPassword}
        showStrength
        autoComplete="new-password"
      />

      {/* With requirements checklist */}
      <PasswordInput
        label="Create Password"
        value={password}
        onChange={setPassword}
        showStrength
        showRequirements
        minLength={12}
      />

      {/* Custom requirements for PIN */}
      <PasswordInput
        label="PIN Code"
        placeholder="6-digit PIN"
        showStrength
        showRequirements
        minLength={6}
        requireUppercase={false}
        requireLowercase={false}
        requireSpecial={false}
        requireNumbers={true}
      />
    </>
  )
}

Features

Built-in functionality

  • Visibility toggle: Show/hide password with eye icon
  • Strength meter: Visual indicator of password strength
  • Requirements checklist: Live validation against rules
  • Configurable requirements: Customize validation rules
  • Three sizes: Small, medium, and large variants
  • Error state: Display validation error messages
  • Autocomplete support: Works with password managers
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

Input type toggles between password and textToggle button has aria-labelError messages linked via aria-describedby

Keyboard Navigation

KeyAction
TabNavigate between input and toggle
Enter/SpaceToggle password visibility

Notes

  • Password hidden by default for security
  • Strength indicator uses color and text
  • Requirements checklist uses checkmarks
  • Error state indicated by color and border

Related Components