Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
I

ink

> 前端框架
Open source

🌈 React for interactive command-line apps

39.5K stars0 likes4 views
WebsiteGitHub

About

🌈 React for interactive command-line apps


React for CLIs. Build and test your CLI output using components. Ink provides the same component-based UI building experience that React offers in the browser, but for command-line apps. It uses Yoga to build Flexbox layouts in the terminal, so most CSS-like properties are available in Ink as well. If you are already familiar with React, you already know Ink.

Since Ink is a React renderer, all features of React are supported. Head over to the React website for documentation on how to use it. Only Ink's methods are documented in this readme.

Fully AI-generated pull requests are not accepted. You can use AI, but should be verified and cleaned up by a human. Only Opus 4.6+ (high-effort) and Codex 5.4+ (extra high) are accepted models. Preferably created with Opus and verified by Codex.


Install

bash
npm install ink react

[!NOTE] This readme documents the upcoming version of Ink. For the latest stable release, see Ink on npm.

Usage

javascript
import React, {useState, useEffect} from 'react';
import {render, Text} from 'ink';

const Counter = () => {
	const [counter, setCounter] = useState(0);

	useEffect(() => {
		const timer = setInterval(() => {
			setCounter(previousCounter => previousCounter + 1);
		}, 100);

		return () => {
			clearInterval(timer);
		};
	}, []);

	return <Text color="green">{counter} tests passed</Text>;
};

render(<Counter />);

Who's Using Ink?

  • Claude Code - An agentic coding tool made by Anthropic.
  • Gemini CLI - An agentic coding tool made by Google.
  • GitHub Copilot CLI - Just say what you want the shell to do.
  • Canva CLI - CLI for creating and managing Canva Apps.
  • Cloudflare's Wrangler - The CLI for Cloudflare Workers.
  • Linear - Linear built an internal CLI for managing deployments, configs, and other housekeeping tasks.
  • Gatsby - Gatsby is a modern web framework for blazing-fast websites.
  • tap - A Test-Anything-Protocol library for JavaScript.
  • Terraform CDK - Cloud Development Kit (CDK) for HashiCorp Terraform.
  • Specify CLI - Automate the distribution of your design tokens.
  • Twilio's SIGNAL - CLI for Twilio's SIGNAL conference. Blog post.
  • Typewriter - Generates strongly-typed Segment analytics clients from arbitrary JSON Schema.
  • Prisma - The unified data layer for modern applications.
  • Blitz - The Fullstack React Framework.
  • New York Times - NYT uses Ink's kyt - a toolkit that encapsulates and manages the configuration for web apps.
  • tink - A next-generation runtime and package manager.
  • Inkle - A Wordle game.
  • loki - Visual regression testing tool for Storybook.
  • Bit - Build, distribute, and collaborate on components.
  • Remirror - Your friendly, world-class editor toolkit.
  • Prime - Open-source GraphQL CMS.
  • emoj - Find relevant emojis.
  • emma - Find and install npm packages easily.
  • npm-check-extras - Check for outdated and unused dependencies, and run update/delete actions on selected ones.
  • swiff - Multi-environment command-line tools for time-saving web developers.
  • share - Share files quickly.
  • Kubelive - A CLI for Kubernetes that provides live data about the cluster and its resources.
  • changelog-view - View changelogs.
  • cfpush - Interactive Cloud Foundry tutorial.
  • startd - Turn your React component into a web app.
  • wiki-cli - Search Wikipedia and read article summaries.
  • garson - Build interactive, config-based command-line interfaces.
  • git-contrib-calendar - Display a contributions calendar for any Git repository.
  • gitgud - Interactive command-line GUI for Git.
  • Autarky - Find and delete old node_modules directories to free up disk space.
  • fast-cli - Test your download and upload speeds.
  • tasuku - Minimal task runner.
  • mnswpr - A Minesweeper game.
  • lrn - Learning by repetition.
  • turdle - A Wordle game.
  • Shopify CLI - Build apps, themes, and storefronts for the Shopify platform.
  • ToDesktop CLI - All-in-one platform for building Electron apps.
  • Walle - A full-featured crypto wallet for EVM networks.
  • Sudoku - A Sudoku game.
  • Sea Trader - A Taipan!-inspired trading simulator game.
  • srtd - Live-reloading SQL templates for Supabase projects.
  • tweakcc - Customize your Claude Code styling.
  • argonaut - Manage Argo CD resources.
  • Qodo Command - Build, run, and manage AI agents.
  • Nanocoder - A community-built, local-first AI coding agent with multi-provider support.
  • dev3000 - An AI agent MCP orchestrator and developer browser.
  • Neovate Code - An agentic coding tool made by AntGroup.
  • instagram-cli - Instagram client.
  • ElevenLabs CLI - ElevenLabs agents client.
  • SSH AI Chat - Chat with AI over SSH.
  • Deep Code CLI - AI coding assistant optimized for the DeepSeek model.

(PRs welcome. Append new entries at the end. Repos must have 100+ stars and showcase Ink beyond a basic list picker.)

Contents

  • Getting Started
  • App Lifecycle
  • Components
    • <Text>
    • <Box>
    • <Newline>
    • <Spacer>
    • <Static>
    • <Transform>
  • Hooks
    • useInput
    • usePaste
    • useApp
    • useStdin
    • useStdout
    • useBoxMetrics
    • useStderr
    • useWindowSize
    • useFocus
    • useFocusManager
    • useCursor
    • useAnimation
  • API
  • Testing
  • Using React Devtools
  • Screen Reader Support
  • Useful Components
  • Useful Hooks
  • Recipes
  • Examples
  • Continuous Integration

Getting Started

Use create-ink-app to quickly scaffold a new Ink-based CLI.

bash
npx create-ink-app my-ink-cli

Alternatively, create a TypeScript project:

bash
npx create-ink-app --typescript my-ink-cli
Manual JavaScript setup

Ink requires the same Babel setup as you would do for regular React-based apps in the browser.

Set up Babel with a React preset to ensure all examples in this readme work as expected. After installing Babel, install @babel/preset-react and insert the following configuration in babel.config.json:

bash
npm install --save-dev @babel/preset-react
json
{
	"presets": ["@babel/preset-react"]
}

Next, create a file source.js, where you'll type code that uses Ink:

javascript
import React from 'react';
import {render, Text} from 'ink';

const Demo = () => <Text>Hello World</Text>;

render(<Demo />);

Then, transpile this file with Babel:

bash
npx babel source.js -o cli.js

Now you can run cli.js with Node.js:

bash
node cli

If you don't like transpiling files during development, you can use import-jsx or @esbuild-kit/esm-loader to import a JSX file and transpile it on the fly.

Ink uses Yoga, a Flexbox layout engine, to build great user interfaces for your CLIs using familiar CSS-like properties you've used when building apps for the browser. It's important to remember that each element is a Flexbox container. Think of it as if every <div> in the browser had display: flex. See <Box> built-in component below for documentation on how to use Flexbox layouts in Ink. Note that all text must be wrapped in a <Text> component.

App Lifecycle

An Ink app is a Node.js process, so it stays alive only while there is active work in the event loop (timers, pending promises, useInput listening on stdin, etc.). If your component tree has no async work, the app will render once and exit immediately.

To exit the app, press Ctrl+C (enabled by default via exitOnCtrlC), call exit() from useApp inside a component, or call unmount() on the object returned by render().

Use waitUntilExit() to run code after the app is unmounted:

javascript
const {waitUntilExit} = render(<MyApp />);

await waitUntilExit();

console.log('App exited');

Components

<Text>

This component can display text and change its style to make it bold, underlined, italic, or strikethrough.

javascript
import {render, Text} from 'ink';

const Example = () => (
	<>
		<Text color="green">I am green</Text>
		<Text color="black" backgroundColor="white">
			I am black on white
		</Text>
		<Text color="#ffffff">I am white</Text>
		<Text bold>I am bold</Text>
		<Text italic>I am italic</Text>
		<Text underline>I am underline</Text>
		<Text strikethrough>I am strikethrough</Text>
		<Text inverse>I am inversed</Text>
	</>
);

render(<Example />);

[!NOTE] <Text> allows only text nodes and nested <Text> components inside of it. For example, <Box> component can't be used inside <Text>.

color

Type: string

Change text color. Ink uses chalk under the hood, so all its functionality is supported.

javascript
<Text color="green">Green</Text>
<Text color="#005cc5">Blue</Text>
<Text color="rgb(232, 131, 136)">Red</Text>

backgroundColor

Type: string

Same as color above, but for background.

`

Issues· 35 open

View all issuesOpen on GitHub
  • #1034

    useCursor position is lost after a sibling-only re-render

    Updated Sep 29, 2026
  • #1035

    Support column-level incremental updates to avoid rewriting unchanged regions

    Updated Sep 29, 2026
  • #1032

    Output caches are rebuilt on every render, so each frame re-tokenizes and re-measures the whole screen

    Updated Sep 24, 2026
  • #1029

    `minWidth` and `maxWidth` accept percentages the docs say are unsupported

    Updated Sep 20, 2026
  • #1023

    Incremental rendering does not repaint when a terminal height shrink makes the frame fill the viewport

    Updated Sep 20, 2026
  • #834

    Suggestion: Removing create-ink-app from README

    Updated Sep 20, 2026
  • #1003

    Small browser/custom host entry

    Updated Sep 18, 2026
  • #759

    Input Lag, Characters Drop and Cursor position issue in languages using IME(CJK)

    Updated Sep 16, 2026
  • #978

    Native (external) memory leak on repeated render/unmount of a component using useStdin().setRawMode()

    Updated Aug 24, 2026
  • #660

    multiline simple text editor

    Updated Aug 16, 2026

> Tags

TypeScriptclicommand-lineflexboxinteractive

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架