# useInputPassword Hook that manages password input with mask toggling and controlled or uncontrolled value state. ## Usage ```tsx import { useInputPassword } from '@primereact/headless/inputpassword'; ``` ```tsx const { rootProps, state, toggleMask } = useInputPassword(); return ; ``` `useInputPassword` manages input type toggling between `password` and `text`, along with value state. See [Primitive](/docs/primitive/components/inputpassword) for a component-based API. ## Features - **Mask state**, tracks current visibility in `state.mask` and flips the input's `type` attribute accordingly - **Value state**, `state.value` holds the current input text for controlled or uncontrolled usage - **Toggle action**, `toggleMask()` switches between masked and unmasked modes imperatively - **Independent control**, value and mask can be controlled separately via `value`/`onValueChange` and `mask`/`onMaskChange` ## Working with callbacks ### Controlled value Pass `value` and `onValueChange` to drive the input from outside state, required for form libraries or validation flows. ```tsx const [value, setValue] = React.useState(''); useInputPassword({ value, onValueChange: (e) => setValue(e.value) }); ``` ### Controlled mask Pass `mask` and `onMaskChange` when the visibility state is owned by a parent (for example, syncing across multiple fields). ```tsx const [masked, setMasked] = React.useState(true); useInputPassword({ mask: masked, onMaskChange: (e) => setMasked(e.value) }); ``` ### Toggle button Call `toggleMask()` from a show/hide button, driving its label from `state.mask`. ```tsx const { rootProps, toggleMask, state } = useInputPassword(); ``` ## Styling with data attributes The root input includes `data-scope="inputpassword"` and `data-part="root"` for styling. ```css [data-scope='inputpassword'][data-part='root'] { padding: 0.5rem; border: 1px solid #ccc; border-radius: 0.25rem; } [data-scope='inputpassword'][data-part='root']:focus { border-color: var(--p-primary-color); outline: none; } ``` ## API ### useInputPassword ## Accessibility Standard text input behavior plus a toggle to reveal or hide the masked value. See [Primitive](/docs/primitive/components/inputpassword#accessibility) for full WAI-ARIA compliance details.