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

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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 14 May 2024

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