Installation
Dependencies
This component requires the following dependencies:alert-dialog- shadcn/ui alert dialog componentbutton- shadcn/ui button componentinput- shadcn/ui input componentlabel- shadcn/ui label componentlucide-react- Icon library (EyeIcon, EyeOffIcon)
Usage
Features
- Password confirmation - Requires password entry for destructive actions
- Visibility toggle - Eye icon to show/hide password
- Form validation - Uses HTML5 required attribute
- Form submission - Handles submit event properly
- AlertDialog - Uses AlertDialog component for important confirmations
- Destructive styling - Red button to emphasize danger
- Accessible - Proper ARIA labels for password visibility toggle
Component Structure
The component includes:AlertDialogwrapper with controlled stateAlertDialogTriggerwith destructive variantAlertDialogContentcontaining the formAlertDialogHeaderwith warning title and description- Password input field with visibility toggle button
- Eye/EyeOff icons for password visibility control
AlertDialogFooterwith Cancel and Delete buttons- Form submit handler to prevent default and close dialog
- State management for open/close and password visibility
This component uses AlertDialog instead of Dialog to prevent accidental dismissal. The password field includes proper accessibility attributes like
aria-label, aria-pressed, and aria-controls.