3.3.1 • Published 6 years ago

react-password-mask v3.3.1

Weekly downloads
557
License
MIT
Repository
github
Last release
6 years ago

React Password Mask

Show/hide the contents of a password field.

Circle CI Coverage Status See Demo

Installation

$ npm install react-password-mask

Usage

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

Unstyled Example

Use useVendorStyles={false} to disable the default CSS styles from the package. You can then style the component from scratch using inputStyles/buttonStyles or inputClassName/buttonClassName.

<PasswordMask
  id="password"
  name="password"
  value={this.state.password}
  onChange={this.handleChange.bind(this)}
  useVendorStyles={false}
/>

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 applied to the container.
inputClassNamestringA space-separated list of HTML class attributes, applied to the password field.
buttonClassNamestringA space-separated list of HTML class attributes, applied to the show/hide button.
placeholderstringThe HTML placeholder attribute used for the password field.
autoFocusbooleanThe HTML autofocus attribute used for the password field.
maxLengthnumberThe HTML maxlength 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.
onKeyDownfunctionA callback function to be invoked when a key is pressed inside the input field. 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.
inputStylesobjectInline CSS styles to be applied to the password field.
buttonStylesobjectInline CSS styles to be applied to the show/hide button.
useVendorStylesbooleanWhether the vendor styles of this package should be applied at all. Default: true
showButtonContentelement, stringThe HTML content of the show button.
hideButtonContentelement, stringThe HTML content of the 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

3.3.1

6 years ago

3.3.0

6 years ago

3.2.0

6 years ago

3.1.2

6 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.5.1

7 years ago

2.4.6

7 years ago

2.4.5

7 years ago

2.4.4

7 years ago

2.4.3

7 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.9

7 years ago

2.3.8

7 years ago

2.3.7

7 years ago

2.3.6

7 years ago

2.3.5

7 years ago

2.3.4

7 years ago

2.3.3

7 years ago

2.3.2

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago