Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Repository files navigation

React Password Mask

Show/hide the contents of a password field.

Circle CICoverage StatusSee Demo

Installation

$ npm install react-password-mask

Usage

importPasswordMaskfrom'react-password-mask';
<PasswordMaskid="password"name="password"placeholder="Enter password"value={this.state.password}onChange={this.handleChange.bind(this)}/>

Options

optiontypedescription
valueanyThe value of the password field.
idstringThe HTML id attribute used for the password field.
namestringThe HTML name attribute used for the password field.
classNamestringA space-separated list of HTML class attributes.
placeholderstringThe HTML placeholder attribute used for the password field.
onChangefunctionA callback function to be invoked when the value of the field changes. Receives an argument containing the React SyntheticEvent object.
onShowfunctionA callback function to be invoked when the value of the field is shown. Receives an argument containing the current value of the field.
onHidefunctionA callback function to be invoked when the value of the field is masked. Receives an argument containing the current value of the field.
onTogglefunctionA callback function to be invoked when the value of the field is shown or masked. Receives an argument containing the current value of the field.
inputStylesobjectThe CSS styles to be applied to the password field.
buttonStylesobjectThe CSS styles to be applied to the show/hide button.

Development

Install dependencies:

$ npm install

Run the example app at http://localhost:8080:

$ npm run example

Run tests using jest:

$ npm test

Update test snapshots:

$ npm run test:update

Run tests and watch for code changes:

$ npm run test:watch

License

MIT

About

Show/hide the contents of a password field.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages