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

ink

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink

React for CLI

  • 3.0.0-1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
427K
decreased by-55.54%
Maintainers
2
Weekly downloads
 
Created

What is ink?

Ink is a React-based framework for building command-line interface (CLI) applications. It allows developers to use React components to create interactive and dynamic CLI tools.

What are ink's main functionalities?

Rendering Text

Ink allows you to render text in the terminal using React components. The example demonstrates a simple 'Hello, world!' text rendering.

const { render, Text } = require('ink');

const App = () => <Text>Hello, world!</Text>;

render(<App />);

Handling User Input

Ink provides hooks like `useInput` to handle user input. This example shows how to exit the application when the user presses 'q'.

const { render, Text, useInput } = require('ink');

const App = () => {
  useInput((input, key) => {
    if (input === 'q') {
      process.exit();
    }
  });

  return <Text>Press 'q' to exit.</Text>;
};

render(<App />);

Using Components

Ink supports layout components like `Box` to arrange other components. This example demonstrates a vertical layout with two text components.

const { render, Box, Text } = require('ink');

const App = () => (
  <Box flexDirection="column">
    <Text>Hello</Text>
    <Text>World</Text>
  </Box>
);

render(<App />);

Styling Text

Ink allows you to style text using properties like `color`. This example shows how to render green-colored text.

const { render, Text } = require('ink');

const App = () => (
  <Text color="green">This is green text</Text>
);

render(<App />);

Other packages similar to ink

Keywords

FAQs

Package last updated on 21 Jun 2020

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