Note: This component is deprecated in favor of ink-text-input. Password input could be simulated with <TextInput mask="*"/>
.
Password input component for Ink.
$ npm install ink-password-input
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/>);
Type: string
Value to display in a password input.
Type: string
Default: *
Mask char to replace each char of the value
with.
Type: string
Text to display when value
is empty.
Type: Function
Function to call when value updates.
Type: Function
Function to call when user press Enter.
MIT © Vadim Demedes