Password input component for Ink
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
media
src
.editorconfig
.gitattributes
.gitignore
.npmrc
.travis.yml
license
package.json
readme.md
test.js

readme.md

ink-password-input Build Status

Password input component for Ink.

Install

$ npm install ink-password-input

Usage

const {h, render, Component} = require('ink');
const PasswordInput = require('ink-password-input');

class Auth extends Component {
	constructor(props) {
		super(props);

		this.state = {
			password: ''
		};

		this.handleChange = this.handleChange.bind(this);
		this.handleSubmit = this.handleSubmit.bind(this);
	}

	render(props, state) {
		return (
			<span>
				Password:

				<PasswordInput
					value={state.password}
					placeholder="Enter your password"
					onChange={this.handleChange}
					onSubmit={this.handleSubmit}
				/>
			</span>
		);
	}

	handleChange(value) {
		this.setState({
			password: value
		});
	}

	handleSubmit(value) {
		// Password submitted
	}
}

render(<Auth/>);

Props

value

Type: string

Value to display in a password input.

mask

Type: string
Default: *

Mask char to replace each char of the value with.

placeholder

Type: string

Text to display when value is empty.

onChange

Type: Function

Function to call when value updates.

onSubmit

Type: Function

Function to call when user press Enter.

License

MIT © Vadim Demedes