PasswordInput
Capture password data from user
Source
LLM docs
Docs
PackageIcon
Usage
PasswordInput component supports Input and Input.Wrapper component features and all input element props. The PasswordInput documentation does not include all features supported by the component – see the Input documentation to learn about all available features.
Input description
Loading state
Set loading prop to display a loading indicator. By default, the loader is displayed on the right side of the input.
You can change the position with the loadingPosition prop to 'left' or 'right'. This is useful for async operations like API calls, searches, or validations:
Controlled
Uncontrolled
PasswordInput can be used with uncontrolled forms the same way as a native input[type="password"].
Set the name attribute to include password input value in FormData object on form submission.
To control the initial value in uncontrolled forms, use the defaultValue prop.
Example usage of uncontrolled PasswordInput with FormData:
Controlled visibility toggle
Control the visibility state with the visible and onVisibilityChange props.
For example, the props can be used to sync visibility state between two inputs:
Change visibility toggle icon
To change the visibility toggle icon, pass a React component that accepts the reveal prop to visibilityToggleIcon:
Strength meter example
Password strength meter example with the Progress and Popover components:
Usage without visibility toggle
If you do not need the visibility toggle button, use the TextInput component instead:
Left and right sections
PasswordInput supports leftSection and rightSection props. These sections are rendered with absolute positioning inside the input wrapper. You can use them to display icons, input controls, or any other elements.
You can use the following props to control sections styles and content:
rightSection/leftSection– React node to render on the corresponding side of inputrightSectionWidth/leftSectionWidth– controls the width of the right section and padding on the corresponding side of the input. By default, it is controlled by the componentsizeprop.rightSectionPointerEvents/leftSectionPointerEvents– controls thepointer-eventsproperty of the section. If you want to render a non-interactive element, set it tononeto pass clicks through to the input.
Note that when the rightSection prop is used, the visibility toggle button is not rendered.
Error state
Invalid name
Disabled
When the disabled prop is set, the visibility toggle button is hidden:
Styles API
PasswordInput supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.
Description
Error
Component Styles API
Hover over selectors to highlight corresponding elements
Get element ref
Accessibility
If PasswordInput is used without the label prop, it will not be announced properly by screen readers:
Set aria-label to make the input accessible. In this case the label will not be visible, but screen readers will announce it:
If the label prop is set, the input will be accessible and it is not required to set aria-label:
To set aria-label on the visibility toggle button, use the visibilityToggleButtonProps prop: