PasswordInput
Capture password data from user
Source
Docs
Package
Usage
PasswordInput component supports Input and Input.Wrapper components features and all input element props. PasswordInput documentation does not include all features supported by the component – see Input documentation to learn about all available features.
Input description
Controlled
Controlled visibility toggle
Control visibility state with visible and onVisibilityChange props,
for example, the props can be used to sync visibility state between two inputs:
Change visibility toggle icon
To change visibility toggle icon, pass a React component that accepts reveal prop to visibilityToggleIcon:
Strength meter example
Password strength meter example with Progress and Popover components:
Usage without visibility toggle
If you do not need visibility toggle button, use TextInput component instead:
Left and right sections
PasswordInput supports leftSection and rightSection props. These sections are rendered with absolute position 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 width of the right section and padding on the corresponding side of the input. By default, it is controlled by componentsizeprop.rightSectionPointerEvents/leftSectionPointerEvents– controlspointer-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 rightSection prop is used, visibility toggle button is not rendered.
Error state
Invalid name
Disabled
When disabled prop is set, visibility toggle button is hidden:
Styles API
PasswordInput supports Styles API, you can add styles to any inner element of the component withclassNames prop. Follow 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 label prop, it will not be announced properly by screen reader:
Set aria-label to make the input accessible. In this case label will not be visible, but screen reader will announce it:
If label prop is set, input will be accessible it is not required to set aria-label:
To set aria-label on the visibility toggle button, use visibilityToggleButtonProps prop: