/ink-password-input

Password input component for Ink

Primary LanguageJavaScriptMIT LicenseMIT

Note: This component is deprecated in favor of ink-text-input. Password input could be simulated with <TextInput mask="*"/>.

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