Introducing PrimeReact v11-alpha 🎉Discover Now

InputPassword

An unstyled password input with mask toggling and controlled or uncontrolled value state.

Build fully custom password inputs with complete control over layout and styling.

basic-demo

Pre-styled Versions

Choose a pre-styled library to use InputPassword with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Dynamic input type toggling between password and text for visibility control
  • Controlled and uncontrolled modes for both value and mask state
  • toggleMask() method exposed on the component instance for programmatic mask switching

Usage#

import { InputPassword } from 'primereact/inputpassword';
<InputPassword />

Behavior#

Polymorphic Rendering#

Use as to change the rendered input element.

<InputPassword as="input" />

Render Function Children#

InputPassword accepts a render function providing access to the component instance.

<InputPassword>{(instance) => <span>{instance.state.mask ? 'Hidden' : 'Visible'}</span>}</InputPassword>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

InputPassword#

AttributeValue
data-scope"password"
data-part"root"

Defines passthrough(pt) options of InputPassword component.

labeltypedescription
rootInputPasswordPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

Value to describe the component can either be provided via label tag combined with id prop or using aria-labelledby, aria-label props. Screen reader is notified about the changes to the strength of the password using a section that has aria-live while typing.

Keyboard Support#

KeyFunction
tabMoves focus to the input.