Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ink-text-input

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink-text-input

Text input component for Ink

  • 5.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
86K
decreased by-53.48%
Maintainers
1
Weekly downloads
 
Created

What is ink-text-input?

The ink-text-input package is a React component for Ink, a React renderer for command-line interfaces. It allows developers to create interactive text input fields in their CLI applications.

What are ink-text-input's main functionalities?

Basic Text Input

This feature allows you to create a basic text input field where users can type in their input. The state of the input is managed using React's useState hook.

const { render, Text } = require('ink');
const TextInput = require('ink-text-input').default;
const React = require('react');

const App = () => {
  const [value, setValue] = React.useState('');

  return (
    <>
      <Text>Enter your name: </Text>
      <TextInput value={value} onChange={setValue} />
    </>
  );
};

render(<App />);

Password Input

This feature allows you to create a password input field where the input is masked with a specified character, such as an asterisk (*).

const { render, Text } = require('ink');
const TextInput = require('ink-text-input').default;
const React = require('react');

const App = () => {
  const [value, setValue] = React.useState('');

  return (
    <>
      <Text>Enter your password: </Text>
      <TextInput value={value} onChange={setValue} mask="*" />
    </>
  );
};

render(<App />);

Submit Handler

This feature allows you to handle the submission of the input value. When the user presses Enter, the onSubmit handler is called, and you can perform actions such as logging the input value.

const { render, Text } = require('ink');
const TextInput = require('ink-text-input').default;
const React = require('react');

const App = () => {
  const [value, setValue] = React.useState('');

  const handleSubmit = () => {
    console.log('Submitted value:', value);
  };

  return (
    <>
      <Text>Enter your name: </Text>
      <TextInput value={value} onChange={setValue} onSubmit={handleSubmit} />
    </>
  );
};

render(<App />);

Other packages similar to ink-text-input

Keywords

FAQs

Package last updated on 01 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc