PasswordInput
A secure text input with built-in visibility toggle for password fields.
Import
Usage
Examples
Custom toggle labels
Custom toggle icons
Inheritance
PasswordInput extends the <Input /> component and inherits all of its props and functionality. This means you can use any Input prop with PasswordInput, including:
size,radius,variant,colorlabel,labelAlign,description,messagestatus,required,isLoading,disabledstartContent,className, and all native input attributes
Reference: For a complete list of inherited props with detailed descriptions, see the Input documentation.
What PasswordInput adds
PasswordInput extends Input with the following additional features:
| Feature | Description |
|---|---|
| Visibility Toggle | A built-in eye icon button that toggles between showing and hiding the password text |
| Toggle Aria Label | Dynamic aria-label for the toggle button that updates based on visibility state |
| Custom Icons | Ability to override the default eye icons with custom icons |
| AutoComplete | Defaults to "current-password" for better password manager integration |
What PasswordInput modifies
| Modification | Description |
|---|---|
type | Controlled internally - toggles between "password" and "text" |
endContent | Used internally for the toggle button - not available as a prop |
autoComplete | Defaults to "current-password" instead of "off" |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
toggleAriaLabel | (show: boolean) => string | (show) => show ? "Hide password" : "Show password" | Function returning aria-label for toggle button |
offIcon | ReactNode | EyeOffIcon | Icon shown when password is visible (hide button) |
onIcon | ReactNode | EyeIcon | Icon shown when password is hidden (show button) |
autoComplete | string | "current-password" | Autocomplete attribute for password managers |
Excluded Props
The following Input props are not available on PasswordInput because they are controlled internally:
| Prop | Reason |
|---|---|
type | Controlled internally to toggle between "password" and "text" |
endContent | Used internally for the toggle button |
All other Input props are fully supported. See the Input documentation for the complete list.
Global Configuration
PasswordInput inherits all global configuration from Input since it wraps the Input component. See the Input docs for configuration options.
Accessibility
- Renders a native
<input>withtype="password"ortype="text"depending on visibility state - Toggle button includes a dynamic
aria-labelthat updates based on visibility state - Toggle button has
tabIndex={-1}to prevent focus interference with password managers - Uses
aria-describedbyfor associated description and message text - Supports
disabledstate with proper styling - Implements
focus-visiblerings for keyboard navigation - Toggle button is accessible via keyboard (focusable with
tabIndex={-1}for programmatic focus only)
Notes
- Toggle Behavior: Clicking the eye icon toggles password visibility between
passwordandtextinput types. - Password Managers: The toggle button uses
tabIndex={-1}to prevent issues with password manager autofill. - Custom Aria Labels: Use
toggleAriaLabelto provide custom aria labels for the toggle button based on visibility state. - Custom Icons: The
onIcon(show button) andoffIcon(hide button) props allow you to replace the default eye icons with custom React nodes. - All Input Props: This component accepts all props from the Input component (except
typeandendContent), making it highly customizable. - AutoComplete: Defaults to
"current-password"for better compatibility with password managers. Can be overridden if needed.