{"id":13395413,"url":"https://github.com/vadimdemedes/ink","last_synced_at":"2026-04-17T09:01:43.985Z","repository":{"id":37336068,"uuid":"94061307","full_name":"vadimdemedes/ink","owner":"vadimdemedes","description":"🌈 React for interactive command-line apps","archived":false,"fork":false,"pushed_at":"2026-04-14T15:21:50.000Z","size":2103,"stargazers_count":37667,"open_issues_count":23,"forks_count":956,"subscribers_count":123,"default_branch":"master","last_synced_at":"2026-04-14T17:19:51.181Z","etag":null,"topics":["cli","command-line","flexbox","interactive","javascript","react"],"latest_commit_sha":null,"homepage":"https://term.ink","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vadimdemedes.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"vadimdemedes","custom":"https://www.comebackalive.in.ua"}},"created_at":"2017-06-12T06:12:28.000Z","updated_at":"2026-04-14T17:06:37.000Z","dependencies_parsed_at":"2023-12-23T13:03:14.179Z","dependency_job_id":"9c7e8e01-c27f-489e-ab57-41db5282e92e","html_url":"https://github.com/vadimdemedes/ink","commit_stats":{"total_commits":584,"total_committers":116,"mean_commits":"5.0344827586206895","dds":"0.39212328767123283","last_synced_commit":"2090ad9779be59dea71d173eb49785b7bd4495d0"},"previous_names":[],"tags_count":95,"template":false,"template_full_name":null,"purl":"pkg:github/vadimdemedes/ink","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vadimdemedes","download_url":"https://codeload.github.com/vadimdemedes/ink/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vadimdemedes%2Fink/sbom","scorecard":{"id":307108,"data":{"date":"2025-08-11","repo":{"name":"github.com/vadimdemedes/ink","commit":"56a5a7f5c2975e03c50b71ef5362f64532e278b6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.9,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":6,"reason":"Found 19/30 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"18 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/vadimdemedes/ink/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/vadimdemedes/ink/test.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/test.yml:18","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license:0","Info: FSF or OSI recognized license: MIT License: license:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 19 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T22:20:58.320Z","repository_id":37336068,"created_at":"2025-08-17T22:20:58.320Z","updated_at":"2025-08-17T22:20:58.320Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31817849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","flexbox","interactive","javascript","react"],"created_at":"2024-07-30T17:01:57.362Z","updated_at":"2026-04-17T09:01:43.964Z","avatar_url":"https://github.com/vadimdemedes.png","language":"TypeScript","funding_links":["https://opencollective.com/vadimdemedes","https://www.comebackalive.in.ua"],"categories":["Packages","Uncategorized","十二、React 渲染器（拓展 React 能力）","TypeScript","🛠️ Tech Stack","JavaScript","Projects using `@faker-js/faker`","cli","DevTools","React","包","目录","*.js","🛠️ Developer Tools","命令行","前端开发框架及项目","Command Line Interface","Awesome Tools","📦 Modules/Packages","Command-line utilities","TUI Frameworks","Rendering","react","\u003e 10K ⭐️","React [🔝](#readme)","Node","Table of Contents","Program","[JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)",":books: Libraries","Libraries","Node.js / JavaScript 🟨","Framework"],"sub_categories":["Command-line utilities","Uncategorized","3.  Immutable 工具（辅助状态管理）","Languages","命令行工具","React相关","Node","redux 扩展","macros","其他_文本生成、文本对话",":curly_loop: Typography","React Components","命令行实用工具","工具库","Web","Useful awesome list for Go cli"],"readme":"[![](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\t\u003cimg width=\"240\" alt=\"Ink\" src=\"media/logo.png\"\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\t\u003cbr\u003e\n\u003c/div\u003e\n\n\u003e React for CLIs. Build and test your CLI output using components.\n\n[![Build Status](https://github.com/vadimdemedes/ink/workflows/test/badge.svg)](https://github.com/vadimdemedes/ink/actions)\n[![npm](https://img.shields.io/npm/dm/ink?logo=npm)](https://npmjs.com/package/ink)\n\nInk provides the same component-based UI building experience that React offers in the browser, but for command-line apps.\nIt uses [Yoga](https://github.com/facebook/yoga) to build Flexbox layouts in the terminal, so most CSS-like properties are available in Ink as well.\nIf you are already familiar with React, you already know Ink.\n\nSince Ink is a React renderer, all features of React are supported.\nHead over to the [React](https://reactjs.org) website for documentation on how to use it.\nOnly Ink's methods are documented in this readme.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cp\u003e\n\t\t\u003cp\u003e\n\t\t\t\u003csup\u003e\n\t\t\t\t\u003ca href=\"https://opencollective.com/vadimdemedes\"\u003eMy open source work is supported by the community ❤️\u003c/a\u003e\n\t\t\t\u003c/sup\u003e\n\t\t\u003c/p\u003e\n\t\u003c/p\u003e\n\u003c/div\u003e\n\n## Install\n\n```sh\nnpm install ink react\n```\n\n\u003e [!NOTE]\n\u003e This readme documents the upcoming version of Ink. For the latest stable release, see [Ink on npm](https://www.npmjs.com/package/ink).\n\n## Usage\n\n```jsx\nimport React, {useState, useEffect} from 'react';\nimport {render, Text} from 'ink';\n\nconst Counter = () =\u003e {\n\tconst [counter, setCounter] = useState(0);\n\n\tuseEffect(() =\u003e {\n\t\tconst timer = setInterval(() =\u003e {\n\t\t\tsetCounter(previousCounter =\u003e previousCounter + 1);\n\t\t}, 100);\n\n\t\treturn () =\u003e {\n\t\t\tclearInterval(timer);\n\t\t};\n\t}, []);\n\n\treturn \u003cText color=\"green\"\u003e{counter} tests passed\u003c/Text\u003e;\n};\n\nrender(\u003cCounter /\u003e);\n```\n\n\u003cimg src=\"media/demo.svg\" width=\"600\"\u003e\n\n## Who's Using Ink?\n\n- [Claude Code](https://github.com/anthropics/claude-code) - An agentic coding tool made by Anthropic.\n- [Gemini CLI](https://github.com/google-gemini/gemini-cli) - An agentic coding tool made by Google.\n- [GitHub Copilot CLI](https://github.com/features/copilot/cli) - Just say what you want the shell to do.\n- [Canva CLI](https://www.canva.dev/docs/apps/canva-cli/) - CLI for creating and managing Canva Apps.\n- [Cloudflare's Wrangler](https://github.com/cloudflare/wrangler2) - The CLI for Cloudflare Workers.\n- [Linear](https://linear.app) - Linear built an internal CLI for managing deployments, configs, and other housekeeping tasks.\n- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing-fast websites.\n- [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript.\n- [Terraform CDK](https://github.com/hashicorp/terraform-cdk) - Cloud Development Kit (CDK) for HashiCorp Terraform.\n- [Specify CLI](https://specifyapp.com) - Automate the distribution of your design tokens.\n- [Twilio's SIGNAL](https://github.com/twilio-labs/plugin-signal2020) - CLI for Twilio's SIGNAL conference. [Blog post](https://www.twilio.com/blog/building-conference-cli-in-react).\n- [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema.\n- [Prisma](https://www.prisma.io) - The unified data layer for modern applications.\n- [Blitz](https://blitzjs.com) - The Fullstack React Framework.\n- [New York Times](https://github.com/nytimes/kyt) - NYT uses Ink's `kyt` - a toolkit that encapsulates and manages the configuration for web apps.\n- [tink](https://github.com/npm/tink) - A next-generation runtime and package manager.\n- [Inkle](https://github.com/jrr/inkle) - A Wordle game.\n- [loki](https://github.com/oblador/loki) - Visual regression testing tool for Storybook.\n- [Bit](https://github.com/teambit/bit) - Build, distribute, and collaborate on components.\n- [Remirror](https://github.com/remirror/remirror) - Your friendly, world-class editor toolkit.\n- [Prime](https://github.com/birkir/prime) - Open-source GraphQL CMS.\n- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emojis.\n- [emma](https://github.com/maticzav/emma-cli) - Find and install npm packages easily.\n- [npm-check-extras](https://github.com/akgondber/npm-check-extras) - Check for outdated and unused dependencies, and run update/delete actions on selected ones.\n- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command-line tools for time-saving web developers.\n- [share](https://github.com/marionebl/share-cli) - Share files quickly.\n- [Kubelive](https://github.com/ameerthehacker/kubelive) - A CLI for Kubernetes that provides live data about the cluster and its resources.\n- [changelog-view](https://github.com/jdeniau/changelog-view) - View changelogs.\n- [cfpush](https://github.com/mamachanko/cfpush) - Interactive Cloud Foundry tutorial.\n- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app.\n- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read article summaries.\n- [garson](https://github.com/goliney/garson) - Build interactive, config-based command-line interfaces.\n- [git-contrib-calendar](https://github.com/giannisp/git-contrib-calendar) - Display a contributions calendar for any Git repository.\n- [gitgud](https://github.com/GitGud-org/GitGud) - Interactive command-line GUI for Git.\n- [Autarky](https://github.com/pranshuchittora/autarky) - Find and delete old `node_modules` directories to free up disk space.\n- [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download and upload speeds.\n- [tasuku](https://github.com/privatenumber/tasuku) - Minimal task runner.\n- [mnswpr](https://github.com/mordv/mnswpr) - A Minesweeper game.\n- [lrn](https://github.com/krychu/lrn) - Learning by repetition.\n- [turdle](https://github.com/mynameisankit/turdle) - A Wordle game.\n- [Shopify CLI](https://github.com/Shopify/cli) - Build apps, themes, and storefronts for the Shopify platform.\n- [ToDesktop CLI](https://www.todesktop.com/electron) - All-in-one platform for building Electron apps.\n- [Walle](https://github.com/Pobepto/walle) - A full-featured crypto wallet for EVM networks.\n- [Sudoku](https://github.com/mrozio13pl/sudoku-in-terminal) - A Sudoku game.\n- [Sea Trader](https://github.com/zyishai/sea-trader) - A Taipan!-inspired trading simulator game.\n- [srtd](https://github.com/t1mmen/srtd) - Live-reloading SQL templates for Supabase projects.\n- [tweakcc](https://github.com/Piebald-AI/tweakcc) - Customize your Claude Code styling.\n- [argonaut](https://github.com/darksworm/argonaut) - Manage Argo CD resources.\n- [Qodo Command](https://github.com/qodo-ai/command) - Build, run, and manage AI agents.\n- [Nanocoder](https://github.com/nano-collective/nanocoder) - A community-built, local-first AI coding agent with multi-provider support.\n- [dev3000](https://github.com/vercel-labs/dev3000) - An AI agent MCP orchestrator and developer browser.\n- [Neovate Code](https://github.com/neovateai/neovate-code) - An agentic coding tool made by AntGroup.\n- [instagram-cli](https://github.com/supreme-gg-gg/instagram-cli) - Instagram client.\n- [ElevenLabs CLI](https://github.com/elevenlabs/cli) - ElevenLabs agents client.\n- [SSH AI Chat](https://github.com/miantiao-me/ssh-ai-chat) - Chat with AI over SSH.\n\n*(PRs welcome. Append new entries at the end. Repos must have 100+ stars and showcase Ink beyond a basic list picker.)*\n\n## Contents\n\n- [Getting Started](#getting-started)\n- [App Lifecycle](#app-lifecycle)\n- [Components](#components)\n  - [`\u003cText\u003e`](#text)\n  - [`\u003cBox\u003e`](#box)\n  - [`\u003cNewline\u003e`](#newline)\n  - [`\u003cSpacer\u003e`](#spacer)\n  - [`\u003cStatic\u003e`](#static)\n  - [`\u003cTransform\u003e`](#transform)\n- [Hooks](#hooks)\n  - [`useInput`](#useinputinputhandler-options)\n  - [`usePaste`](#usepastehandler-options)\n  - [`useApp`](#useapp)\n  - [`useStdin`](#usestdin)\n  - [`useStdout`](#usestdout)\n  - [`useBoxMetrics`](#useboxmetricsref)\n  - [`useStderr`](#usestderr)\n  - [`useWindowSize`](#usewindowsize)\n  - [`useFocus`](#usefocusoptions)\n  - [`useFocusManager`](#usefocusmanager)\n  - [`useCursor`](#usecursor)\n- [API](#api)\n- [Testing](#testing)\n- [Using React Devtools](#using-react-devtools)\n- [Screen Reader Support](#screen-reader-support)\n- [Useful Components](#useful-components)\n- [Useful Hooks](#useful-hooks)\n- [Recipes](#recipes)\n- [Examples](#examples)\n- [Continuous Integration](#continuous-integration)\n\n## Getting Started\n\nUse [create-ink-app](https://github.com/vadimdemedes/create-ink-app) to quickly scaffold a new Ink-based CLI.\n\n```sh\nnpx create-ink-app my-ink-cli\n```\n\nAlternatively, create a TypeScript project:\n\n```sh\nnpx create-ink-app --typescript my-ink-cli\n```\n\n\u003cdetails\u003e\u003csummary\u003eManual JavaScript setup\u003c/summary\u003e\n\u003cp\u003e\nInk requires the same Babel setup as you would do for regular React-based apps in the browser.\n\nSet up Babel with a React preset to ensure all examples in this readme work as expected.\nAfter [installing Babel](https://babeljs.io/docs/en/usage), install `@babel/preset-react` and insert the following configuration in `babel.config.json`:\n\n```sh\nnpm install --save-dev @babel/preset-react\n```\n\n```json\n{\n\t\"presets\": [\"@babel/preset-react\"]\n}\n```\n\nNext, create a file `source.js`, where you'll type code that uses Ink:\n\n```jsx\nimport React from 'react';\nimport {render, Text} from 'ink';\n\nconst Demo = () =\u003e \u003cText\u003eHello World\u003c/Text\u003e;\n\nrender(\u003cDemo /\u003e);\n```\n\nThen, transpile this file with Babel:\n\n```sh\nnpx babel source.js -o cli.js\n```\n\nNow you can run `cli.js` with Node.js:\n\n```sh\nnode cli\n```\n\nIf you don't like transpiling files during development, you can use [import-jsx](https://github.com/vadimdemedes/import-jsx) or [@esbuild-kit/esm-loader](https://github.com/esbuild-kit/esm-loader) to `import` a JSX file and transpile it on the fly.\n\n\u003c/p\u003e\n\u003c/details\u003e\n\nInk uses [Yoga](https://github.com/facebook/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.\nIt's important to remember that each element is a Flexbox container.\nThink of it as if every `\u003cdiv\u003e` in the browser had `display: flex`.\nSee [`\u003cBox\u003e`](#box) built-in component below for documentation on how to use Flexbox layouts in Ink.\nNote that all text must be wrapped in a [`\u003cText\u003e`](#text) component.\n\n## App Lifecycle\n\nAn 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`](#useinputinputhandler-options) listening on `stdin`, etc.). If your component tree has no async work, the app will render once and exit immediately.\n\nTo exit the app, press **Ctrl+C** (enabled by default via [`exitOnCtrlC`](#exitonctrlc)), call [`exit()`](#exiterrororresult) from [`useApp`](#useapp) inside a component, or call [`unmount()`](#unmount) on the object returned by [`render()`](#rendertree-options).\n\nUse [`waitUntilExit()`](#waituntilexit) to run code after the app is unmounted:\n\n```jsx\nconst {waitUntilExit} = render(\u003cMyApp /\u003e);\n\nawait waitUntilExit();\n\nconsole.log('App exited');\n```\n\n## Components\n\n### `\u003cText\u003e`\n\nThis component can display text and change its style to make it bold, underlined, italic, or strikethrough.\n\n```jsx\nimport {render, Text} from 'ink';\n\nconst Example = () =\u003e (\n\t\u003c\u003e\n\t\t\u003cText color=\"green\"\u003eI am green\u003c/Text\u003e\n\t\t\u003cText color=\"black\" backgroundColor=\"white\"\u003e\n\t\t\tI am black on white\n\t\t\u003c/Text\u003e\n\t\t\u003cText color=\"#ffffff\"\u003eI am white\u003c/Text\u003e\n\t\t\u003cText bold\u003eI am bold\u003c/Text\u003e\n\t\t\u003cText italic\u003eI am italic\u003c/Text\u003e\n\t\t\u003cText underline\u003eI am underline\u003c/Text\u003e\n\t\t\u003cText strikethrough\u003eI am strikethrough\u003c/Text\u003e\n\t\t\u003cText inverse\u003eI am inversed\u003c/Text\u003e\n\t\u003c/\u003e\n);\n\nrender(\u003cExample /\u003e);\n```\n\n\u003e [!NOTE]\n\u003e `\u003cText\u003e` allows only text nodes and nested `\u003cText\u003e` components inside of it. For example, `\u003cBox\u003e` component can't be used inside `\u003cText\u003e`.\n\n#### color\n\nType: `string`\n\nChange text color.\nInk uses [chalk](https://github.com/chalk/chalk) under the hood, so all its functionality is supported.\n\n```jsx\n\u003cText color=\"green\"\u003eGreen\u003c/Text\u003e\n\u003cText color=\"#005cc5\"\u003eBlue\u003c/Text\u003e\n\u003cText color=\"rgb(232, 131, 136)\"\u003eRed\u003c/Text\u003e\n```\n\n\u003cimg src=\"media/text-color.jpg\" width=\"247\"\u003e\n\n#### backgroundColor\n\nType: `string`\n\nSame as `color` above, but for background.\n\n```jsx\n\u003cText backgroundColor=\"green\" color=\"white\"\u003eGreen\u003c/Text\u003e\n\u003cText backgroundColor=\"#005cc5\" color=\"white\"\u003eBlue\u003c/Text\u003e\n\u003cText backgroundColor=\"rgb(232, 131, 136)\" color=\"white\"\u003eRed\u003c/Text\u003e\n```\n\n\u003cimg src=\"media/text-backgroundColor.jpg\" width=\"226\"\u003e\n\n#### dimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the color (make it less bright).\n\n```jsx\n\u003cText color=\"red\" dimColor\u003e\n\tDimmed Red\n\u003c/Text\u003e\n```\n\n\u003cimg src=\"media/text-dimColor.jpg\" width=\"138\"\u003e\n\n#### bold\n\nType: `boolean`\\\nDefault: `false`\n\nMake the text bold.\n\n#### italic\n\nType: `boolean`\\\nDefault: `false`\n\nMake the text italic.\n\n#### underline\n\nType: `boolean`\\\nDefault: `false`\n\nMake the text underlined.\n\n#### strikethrough\n\nType: `boolean`\\\nDefault: `false`\n\nMake the text crossed with a line.\n\n#### inverse\n\nType: `boolean`\\\nDefault: `false`\n\nInvert background and foreground colors.\n\n```jsx\n\u003cText inverse color=\"yellow\"\u003e\n\tInversed Yellow\n\u003c/Text\u003e\n```\n\n\u003cimg src=\"media/text-inverse.jpg\" width=\"138\"\u003e\n\n#### wrap\n\nType: `string`\\\nAllowed values: `wrap` `truncate` `truncate-start` `truncate-middle` `truncate-end`\\\nDefault: `wrap`\n\nThis property tells Ink to wrap or truncate text if its width is larger than the container.\nIf `wrap` is passed (the default), Ink will wrap text and split it into multiple lines.\nIf `truncate-*` is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off.\n\n```jsx\n\u003cBox width={7}\u003e\n\t\u003cText\u003eHello World\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'Hello\\nWorld'\n\n// `truncate` is an alias to `truncate-end`\n\u003cBox width={7}\u003e\n\t\u003cText wrap=\"truncate\"\u003eHello World\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'Hello…'\n\n\u003cBox width={7}\u003e\n\t\u003cText wrap=\"truncate-middle\"\u003eHello World\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'He…ld'\n\n\u003cBox width={7}\u003e\n\t\u003cText wrap=\"truncate-start\"\u003eHello World\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e '…World'\n```\n\n### `\u003cBox\u003e`\n\n`\u003cBox\u003e` is an essential Ink component to build your layout.\nIt's like `\u003cdiv style=\"display: flex\"\u003e` in the browser.\n\n```jsx\nimport {render, Box, Text} from 'ink';\n\nconst Example = () =\u003e (\n\t\u003cBox margin={2}\u003e\n\t\t\u003cText\u003eThis is a box with margin\u003c/Text\u003e\n\t\u003c/Box\u003e\n);\n\nrender(\u003cExample /\u003e);\n```\n\n#### Dimensions\n\n##### width\n\nType: `number` `string`\n\nWidth of the element in spaces.\nYou can also set it as a percentage, which will calculate the width based on the width of the parent element.\n\n```jsx\n\u003cBox width={4}\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'X   '\n```\n\n```jsx\n\u003cBox width={10}\u003e\n\t\u003cBox width=\"50%\"\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'X    Y'\n```\n\n##### height\n\nType: `number` `string`\n\nHeight of the element in lines (rows).\nYou can also set it as a percentage, which will calculate the height based on the height of the parent element.\n\n```jsx\n\u003cBox height={4}\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'X\\n\\n\\n'\n```\n\n```jsx\n\u003cBox height={6} flexDirection=\"column\"\u003e\n\t\u003cBox height=\"50%\"\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'X\\n\\n\\nY\\n\\n'\n```\n\n##### minWidth\n\nType: `number`\n\nSets a minimum width of the element.\nPercentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.\n\n##### minHeight\n\nType: `number` `string`\n\nSets a minimum height of the element in lines (rows).\nYou can also set it as a percentage, which will calculate the minimum height based on the height of the parent element.\n\n##### maxWidth\n\nType: `number`\n\nSets a maximum width of the element.\nPercentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.\n\n##### maxHeight\n\nType: `number` `string`\n\nSets a maximum height of the element in lines (rows).\nYou can also set it as a percentage, which will calculate the maximum height based on the height of the parent element.\n\n##### aspectRatio\n\nType: `number`\n\nDefines the aspect ratio (width/height) for the element.\n\nUse it with at least one size constraint (`width`, `height`, `minHeight`, or `maxHeight`) so Ink can derive the missing dimension.\n\n#### Padding\n\n##### paddingTop\n\nType: `number`\\\nDefault: `0`\n\nTop padding.\n\n##### paddingBottom\n\nType: `number`\\\nDefault: `0`\n\nBottom padding.\n\n##### paddingLeft\n\nType: `number`\\\nDefault: `0`\n\nLeft padding.\n\n##### paddingRight\n\nType: `number`\\\nDefault: `0`\n\nRight padding.\n\n##### paddingX\n\nType: `number`\\\nDefault: `0`\n\nHorizontal padding. Equivalent to setting `paddingLeft` and `paddingRight`.\n\n##### paddingY\n\nType: `number`\\\nDefault: `0`\n\nVertical padding. Equivalent to setting `paddingTop` and `paddingBottom`.\n\n##### padding\n\nType: `number`\\\nDefault: `0`\n\nPadding on all sides. Equivalent to setting `paddingTop`, `paddingBottom`, `paddingLeft` and `paddingRight`.\n\n```jsx\n\u003cBox paddingTop={2}\u003e\u003cText\u003eTop\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox paddingBottom={2}\u003e\u003cText\u003eBottom\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox paddingLeft={2}\u003e\u003cText\u003eLeft\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox paddingRight={2}\u003e\u003cText\u003eRight\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox paddingX={2}\u003e\u003cText\u003eLeft and right\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox paddingY={2}\u003e\u003cText\u003eTop and bottom\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox padding={2}\u003e\u003cText\u003eTop, bottom, left and right\u003c/Text\u003e\u003c/Box\u003e\n```\n\n#### Margin\n\n##### marginTop\n\nType: `number`\\\nDefault: `0`\n\nTop margin.\n\n##### marginBottom\n\nType: `number`\\\nDefault: `0`\n\nBottom margin.\n\n##### marginLeft\n\nType: `number`\\\nDefault: `0`\n\nLeft margin.\n\n##### marginRight\n\nType: `number`\\\nDefault: `0`\n\nRight margin.\n\n##### marginX\n\nType: `number`\\\nDefault: `0`\n\nHorizontal margin. Equivalent to setting `marginLeft` and `marginRight`.\n\n##### marginY\n\nType: `number`\\\nDefault: `0`\n\nVertical margin. Equivalent to setting `marginTop` and `marginBottom`.\n\n##### margin\n\nType: `number`\\\nDefault: `0`\n\nMargin on all sides. Equivalent to setting `marginTop`, `marginBottom`, `marginLeft` and `marginRight`.\n\n```jsx\n\u003cBox marginTop={2}\u003e\u003cText\u003eTop\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox marginBottom={2}\u003e\u003cText\u003eBottom\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox marginLeft={2}\u003e\u003cText\u003eLeft\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox marginRight={2}\u003e\u003cText\u003eRight\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox marginX={2}\u003e\u003cText\u003eLeft and right\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox marginY={2}\u003e\u003cText\u003eTop and bottom\u003c/Text\u003e\u003c/Box\u003e\n\u003cBox margin={2}\u003e\u003cText\u003eTop, bottom, left and right\u003c/Text\u003e\u003c/Box\u003e\n```\n\n#### Gap\n\n#### gap\n\nType: `number`\\\nDefault: `0`\n\nSize of the gap between an element's columns and rows. A shorthand for `columnGap` and `rowGap`.\n\n```jsx\n\u003cBox gap={1} width={3} flexWrap=\"wrap\"\u003e\n\t\u003cText\u003eA\u003c/Text\u003e\n\t\u003cText\u003eB\u003c/Text\u003e\n\t\u003cText\u003eC\u003c/Text\u003e\n\u003c/Box\u003e\n// A B\n//\n// C\n```\n\n#### columnGap\n\nType: `number`\\\nDefault: `0`\n\nSize of the gap between an element's columns.\n\n```jsx\n\u003cBox columnGap={1}\u003e\n\t\u003cText\u003eA\u003c/Text\u003e\n\t\u003cText\u003eB\u003c/Text\u003e\n\u003c/Box\u003e\n// A B\n```\n\n#### rowGap\n\nType: `number`\\\nDefault: `0`\n\nSize of the gap between an element's rows.\n\n```jsx\n\u003cBox flexDirection=\"column\" rowGap={1}\u003e\n\t\u003cText\u003eA\u003c/Text\u003e\n\t\u003cText\u003eB\u003c/Text\u003e\n\u003c/Box\u003e\n// A\n//\n// B\n```\n\n#### Flex\n\n##### flexGrow\n\nType: `number`\\\nDefault: `0`\n\nSee [flex-grow](https://css-tricks.com/almanac/properties/f/flex-grow/).\n\n```jsx\n\u003cBox\u003e\n\t\u003cText\u003eLabel:\u003c/Text\u003e\n\t\u003cBox flexGrow={1}\u003e\n\t\t\u003cText\u003eFills all remaining space\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n```\n\n##### flexShrink\n\nType: `number`\\\nDefault: `1`\n\nSee [flex-shrink](https://css-tricks.com/almanac/properties/f/flex-shrink/).\n\n```jsx\n\u003cBox width={20}\u003e\n\t\u003cBox flexShrink={2} width={10}\u003e\n\t\t\u003cText\u003eWill be 1/4\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cBox width={10}\u003e\n\t\t\u003cText\u003eWill be 3/4\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n```\n\n##### flexBasis\n\nType: `number` `string`\n\nSee [flex-basis](https://css-tricks.com/almanac/properties/f/flex-basis/).\n\n```jsx\n\u003cBox width={6}\u003e\n\t\u003cBox flexBasis={3}\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'X  Y'\n```\n\n```jsx\n\u003cBox width={6}\u003e\n\t\u003cBox flexBasis=\"50%\"\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n//=\u003e 'X  Y'\n```\n\n##### flexDirection\n\nType: `string`\\\nAllowed values: `row` `row-reverse` `column` `column-reverse`\n\nSee [flex-direction](https://css-tricks.com/almanac/properties/f/flex-direction/).\n\n```jsx\n\u003cBox\u003e\n\t\u003cBox marginRight={1}\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n// X Y\n\n\u003cBox flexDirection=\"row-reverse\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003cBox marginRight={1}\u003e\n\t\t\u003cText\u003eY\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n// Y X\n\n\u003cBox flexDirection=\"column\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n// X\n// Y\n\n\u003cBox flexDirection=\"column-reverse\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n// Y\n// X\n```\n\n##### flexWrap\n\nType: `string`\\\nAllowed values: `nowrap` `wrap` `wrap-reverse`\n\nSee [flex-wrap](https://css-tricks.com/almanac/properties/f/flex-wrap/).\n\n```jsx\n\u003cBox width={2} flexWrap=\"wrap\"\u003e\n\t\u003cText\u003eA\u003c/Text\u003e\n\t\u003cText\u003eBC\u003c/Text\u003e\n\u003c/Box\u003e\n// A\n// B C\n```\n\n```jsx\n\u003cBox flexDirection=\"column\" height={2} flexWrap=\"wrap\"\u003e\n\t\u003cText\u003eA\u003c/Text\u003e\n\t\u003cText\u003eB\u003c/Text\u003e\n\t\u003cText\u003eC\u003c/Text\u003e\n\u003c/Box\u003e\n// A C\n// B\n```\n\n##### alignItems\n\nType: `string`\\\nAllowed values: `flex-start` `center` `flex-end` `stretch` `baseline`\n\nSee [align-items](https://css-tricks.com/almanac/properties/a/align-items/).\n\n```jsx\n\u003cBox alignItems=\"flex-start\"\u003e\n\t\u003cBox marginRight={1}\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003e\n\t\tA\n\t\t\u003cNewline/\u003e\n\t\tB\n\t\t\u003cNewline/\u003e\n\t\tC\n\t\u003c/Text\u003e\n\u003c/Box\u003e\n// X A\n//   B\n//   C\n\n\u003cBox alignItems=\"center\"\u003e\n\t\u003cBox marginRight={1}\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003e\n\t\tA\n\t\t\u003cNewline/\u003e\n\t\tB\n\t\t\u003cNewline/\u003e\n\t\tC\n\t\u003c/Text\u003e\n\u003c/Box\u003e\n//   A\n// X B\n//   C\n\n\u003cBox alignItems=\"flex-end\"\u003e\n\t\u003cBox marginRight={1}\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\t\u003cText\u003e\n\t\tA\n\t\t\u003cNewline/\u003e\n\t\tB\n\t\t\u003cNewline/\u003e\n\t\tC\n\t\u003c/Text\u003e\n\u003c/Box\u003e\n//   A\n//   B\n// X C\n```\n\n##### alignSelf\n\nType: `string`\\\nDefault: `auto`\\\nAllowed values: `auto` `flex-start` `center` `flex-end` `stretch` `baseline`\n\nSee [align-self](https://css-tricks.com/almanac/properties/a/align-self/).\n\n```jsx\n\u003cBox height={3}\u003e\n\t\u003cBox alignSelf=\"flex-start\"\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n// X\n//\n//\n\n\u003cBox height={3}\u003e\n\t\u003cBox alignSelf=\"center\"\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n//\n// X\n//\n\n\u003cBox height={3}\u003e\n\t\u003cBox alignSelf=\"flex-end\"\u003e\n\t\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n//\n//\n// X\n```\n\n##### alignContent\n\nType: `string`\\\nDefault: `flex-start`\\\nAllowed values: `flex-start` `flex-end` `center` `stretch` `space-between` `space-around` `space-evenly`\n\nDefines alignment between flex lines on the cross axis when `flexWrap` creates multiple lines.\nSee [align-content](https://css-tricks.com/almanac/properties/a/align-content/).\nUnlike CSS (`stretch`), Ink defaults to `flex-start` so wrapped lines stay compact and fixed-height boxes don't gain unexpected empty rows unless you opt in to stretching.\n\n##### justifyContent\n\nType: `string`\\\nAllowed values: `flex-start` `center` `flex-end` `space-between` `space-around` `space-evenly`\n\nSee [justify-content](https://css-tricks.com/almanac/properties/j/justify-content/).\n\n```jsx\n\u003cBox justifyContent=\"flex-start\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\u003c/Box\u003e\n// [X      ]\n\n\u003cBox justifyContent=\"center\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\u003c/Box\u003e\n// [   X   ]\n\n\u003cBox justifyContent=\"flex-end\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\u003c/Box\u003e\n// [      X]\n\n\u003cBox justifyContent=\"space-between\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n// [X      Y]\n\n\u003cBox justifyContent=\"space-around\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n// [  X   Y  ]\n\n\u003cBox justifyContent=\"space-evenly\"\u003e\n\t\u003cText\u003eX\u003c/Text\u003e\n\t\u003cText\u003eY\u003c/Text\u003e\n\u003c/Box\u003e\n// [   X   Y   ]\n```\n\n#### Position\n\n##### position\n\nType: `string`\\\nAllowed values: `relative` `absolute` `static`\\\nDefault: `relative`\n\nControls how the element is positioned.\n\nWhen `position` is `static`, `top`, `right`, `bottom`, and `left` are ignored.\n\n##### top\n\nType: `number` `string`\n\nTop offset for positioned elements.\nYou can also set it as a percentage of the parent size.\n\n##### right\n\nType: `number` `string`\n\nRight offset for positioned elements.\nYou can also set it as a percentage of the parent size.\n\n##### bottom\n\nType: `number` `string`\n\nBottom offset for positioned elements.\nYou can also set it as a percentage of the parent size.\n\n##### left\n\nType: `number` `string`\n\nLeft offset for positioned elements.\nYou can also set it as a percentage of the parent size.\n\n#### Visibility\n\n##### display\n\nType: `string`\\\nAllowed values: `flex` `none`\\\nDefault: `flex`\n\nSet this property to `none` to hide the element.\n\n##### overflowX\n\nType: `string`\\\nAllowed values: `visible` `hidden`\\\nDefault: `visible`\n\nBehavior for an element's overflow in the horizontal direction.\n\n##### overflowY\n\nType: `string`\\\nAllowed values: `visible` `hidden`\\\nDefault: `visible`\n\nBehavior for an element's overflow in the vertical direction.\n\n##### overflow\n\nType: `string`\\\nAllowed values: `visible` `hidden`\\\nDefault: `visible`\n\nA shortcut for setting `overflowX` and `overflowY` at the same time.\n\n#### Borders\n\n##### borderStyle\n\nType: `string`\\\nAllowed values: `single` `double` `round` `bold` `singleDouble` `doubleSingle` `classic` | `BoxStyle`\n\nAdd a border with a specified style.\nIf `borderStyle` is `undefined` (the default), no border will be added.\nInk uses border styles from the [`cli-boxes`](https://github.com/sindresorhus/cli-boxes) module.\n\n```jsx\n\u003cBox flexDirection=\"column\"\u003e\n\t\u003cBox\u003e\n\t\t\u003cBox borderStyle=\"single\" marginRight={2}\u003e\n\t\t\t\u003cText\u003esingle\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\n\t\t\u003cBox borderStyle=\"double\" marginRight={2}\u003e\n\t\t\t\u003cText\u003edouble\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\n\t\t\u003cBox borderStyle=\"round\" marginRight={2}\u003e\n\t\t\t\u003cText\u003eround\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\n\t\t\u003cBox borderStyle=\"bold\"\u003e\n\t\t\t\u003cText\u003ebold\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\t\u003c/Box\u003e\n\n\t\u003cBox marginTop={1}\u003e\n\t\t\u003cBox borderStyle=\"singleDouble\" marginRight={2}\u003e\n\t\t\t\u003cText\u003esingleDouble\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\n\t\t\u003cBox borderStyle=\"doubleSingle\" marginRight={2}\u003e\n\t\t\t\u003cText\u003edoubleSingle\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\n\t\t\u003cBox borderStyle=\"classic\"\u003e\n\t\t\t\u003cText\u003eclassic\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n```\n\n\u003cimg src=\"media/box-borderStyle.jpg\" width=\"521\"\u003e\n\nAlternatively, pass a custom border style like so:\n\n```jsx\n\u003cBox\n\tborderStyle={{\n\t\ttopLeft: '↘',\n\t\ttop: '↓',\n\t\ttopRight: '↙',\n\t\tleft: '→',\n\t\tbottomLeft: '↗',\n\t\tbottom: '↑',\n\t\tbottomRight: '↖',\n\t\tright: '←'\n\t}}\n\u003e\n\t\u003cText\u003eCustom\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\nSee example in [examples/borders](examples/borders/borders.tsx).\n\n##### borderColor\n\nType: `string`\n\nChange border color.\nA shorthand for setting `borderTopColor`, `borderRightColor`, `borderBottomColor`, and `borderLeftColor`.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderColor=\"green\"\u003e\n\t\u003cText\u003eGreen Rounded Box\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n\u003cimg src=\"media/box-borderColor.jpg\" width=\"228\"\u003e\n\n##### borderTopColor\n\nType: `string`\n\nChange top border color.\nAccepts the same values as [`color`](#color) in `\u003cText\u003e` component.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderTopColor=\"green\"\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderRightColor\n\nType: `string`\n\nChange the right border color.\nAccepts the same values as [`color`](#color) in `\u003cText\u003e` component.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderRightColor=\"green\"\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderBottomColor\n\nType: `string`\n\nChange the bottom border color.\nAccepts the same values as [`color`](#color) in `\u003cText\u003e` component.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderBottomColor=\"green\"\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderLeftColor\n\nType: `string`\n\nChange the left border color.\nAccepts the same values as [`color`](#color) in `\u003cText\u003e` component.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderLeftColor=\"green\"\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the border color.\nA shorthand for setting `borderTopDimColor`, `borderBottomDimColor`, `borderLeftDimColor`, and `borderRightDimColor`.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderDimColor\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderTopDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the top border color.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderTopDimColor\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderBottomDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the bottom border color.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderBottomDimColor\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderLeftDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the left border color.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderLeftDimColor\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderRightDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the right border color.\n\n```jsx\n\u003cBox borderStyle=\"round\" borderRightDimColor\u003e\n\t\u003cText\u003eHello world\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\n##### borderTop\n\nType: `boolean`\\\nDefault: `true`\n\nDetermines whether the top border is visible.\n\n##### borderRight\n\nType: `boolean`\\\nDefault: `true`\n\nDetermines whether the right border is visible.\n\n##### borderBottom\n\nType: `boolean`\\\nDefault: `true`\n\nDetermines whether the bottom border is visible.\n\n##### borderLeft\n\nType: `boolean`\\\nDefault: `true`\n\nDetermines whether the left border is visible.\n\n#### Background\n\n##### backgroundColor\n\nType: `string`\n\nBackground color for the element.\n\nAccepts the same values as [`color`](#color) in the `\u003cText\u003e` component.\n\n```jsx\n\u003cBox flexDirection=\"column\"\u003e\n\t\u003cBox backgroundColor=\"red\" width={20} height={5} alignSelf=\"flex-start\"\u003e\n\t\t\u003cText\u003eRed background\u003c/Text\u003e\n\t\u003c/Box\u003e\n\n\t\u003cBox backgroundColor=\"#FF8800\" width={20} height={3} marginTop={1} alignSelf=\"flex-start\"\u003e\n\t\t\u003cText\u003eOrange background\u003c/Text\u003e\n\t\u003c/Box\u003e\n\n\t\u003cBox backgroundColor=\"rgb(0, 255, 0)\" width={20} height={3} marginTop={1} alignSelf=\"flex-start\"\u003e\n\t\t\u003cText\u003eGreen background\u003c/Text\u003e\n\t\u003c/Box\u003e\n\u003c/Box\u003e\n```\n\nThe background color fills the entire `\u003cBox\u003e` area and is inherited by child `\u003cText\u003e` components unless they specify their own `backgroundColor`.\n\n```jsx\n\u003cBox backgroundColor=\"blue\" alignSelf=\"flex-start\"\u003e\n\t\u003cText\u003eBlue inherited \u003c/Text\u003e\n\t\u003cText backgroundColor=\"yellow\"\u003eYellow override \u003c/Text\u003e\n\t\u003cText\u003eBlue inherited again\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\nBackground colors work with borders and padding:\n\n```jsx\n\u003cBox backgroundColor=\"cyan\" borderStyle=\"round\" padding={1} alignSelf=\"flex-start\"\u003e\n\t\u003cText\u003eBackground with border and padding\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\nSee example in [examples/box-backgrounds](examples/box-backgrounds/box-backgrounds.tsx).\n\n### `\u003cNewline\u003e`\n\nAdds one or more newline (`\\n`) characters.\nMust be used within `\u003cText\u003e` components.\n\n#### count\n\nType: `number`\\\nDefault: `1`\n\nNumber of newlines to insert.\n\n```jsx\nimport {render, Text, Newline} from 'ink';\n\nconst Example = () =\u003e (\n\t\u003cText\u003e\n\t\t\u003cText color=\"green\"\u003eHello\u003c/Text\u003e\n\t\t\u003cNewline /\u003e\n\t\t\u003cText color=\"red\"\u003eWorld\u003c/Text\u003e\n\t\u003c/Text\u003e\n);\n\nrender(\u003cExample /\u003e);\n```\n\nOutput:\n\n```\nHello\nWorld\n```\n\n### `\u003cSpacer\u003e`\n\nA flexible space that expands along the major axis of its containing layout.\nIt's useful as a shortcut for filling all the available space between elements.\n\nFor example, using `\u003cSpacer\u003e` in a `\u003cBox\u003e` with default flex direction (`row`) will position \"Left\" on the left side and will push \"Right\" to the right side.\n\n```jsx\nimport {render, Box, Text, Spacer} from 'ink';\n\nconst Example = () =\u003e (\n\t\u003cBox\u003e\n\t\t\u003cText\u003eLeft\u003c/Text\u003e\n\t\t\u003cSpacer /\u003e\n\t\t\u003cText\u003eRight\u003c/Text\u003e\n\t\u003c/Box\u003e\n);\n\nrender(\u003cExample /\u003e);\n```\n\nIn a vertical flex direction (`column`), it will position \"Top\" at the top of the container and push \"Bottom\" to the bottom.\nNote that the container needs to be tall enough to see this in effect.\n\n```jsx\nimport {render, Box, Text, Spacer} from 'ink';\n\nconst Example = () =\u003e (\n\t\u003cBox flexDirection=\"column\" height={10}\u003e\n\t\t\u003cText\u003eTop\u003c/Text\u003e\n\t\t\u003cSpacer /\u003e\n\t\t\u003cText\u003eBottom\u003c/Text\u003e\n\t\u003c/Box\u003e\n);\n\nrender(\u003cExample /\u003e);\n```\n\n### `\u003cStatic\u003e`\n\n`\u003cStatic\u003e` component permanently renders its output above everything else.\nIt's useful for displaying activity like completed tasks or logs - things that\ndon't change after they're rendered (hence the name \"Static\").\n\nIt's preferred to use `\u003cStatic\u003e` for use cases like these when you can't know\nor control the number of items that need to be rendered.\n\nFor example, [Tap](https://github.com/tapjs/node-tap) uses `\u003cStatic\u003e` to display\na list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it\nto display a list of generated pages while still displaying a live progress bar.\n\n```jsx\nimport React, {useState, useEffect} from 'react';\nimport {render, Static, Box, Text} from 'ink';\n\nconst Example = () =\u003e {\n\tconst [tests, setTests] = useState([]);\n\n\tuseEffect(() =\u003e {\n\t\tlet completedTests = 0;\n\t\tlet timer;\n\n\t\tconst run = () =\u003e {\n\t\t\t// Fake 10 completed tests\n\t\t\tif (completedTests++ \u003c 10) {\n\t\t\t\tsetTests(previousTests =\u003e [\n\t\t\t\t\t...previousTests,\n\t\t\t\t\t{\n\t\t\t\t\t\tid: previousTests.length,\n\t\t\t\t\t\ttitle: `Test #${previousTests.length + 1}`\n\t\t\t\t\t}\n\t\t\t\t]);\n\n\t\t\t\ttimer = setTimeout(run, 100);\n\t\t\t}\n\t\t};\n\n\t\trun();\n\n\t\treturn () =\u003e {\n\t\t\tclearTimeout(timer);\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t\u003c\u003e\n\t\t\t{/* This part will be rendered once to the terminal */}\n\t\t\t\u003cStatic items={tests}\u003e\n\t\t\t\t{test =\u003e (\n\t\t\t\t\t\u003cBox key={test.id}\u003e\n\t\t\t\t\t\t\u003cText color=\"green\"\u003e✔ {test.title}\u003c/Text\u003e\n\t\t\t\t\t\u003c/Box\u003e\n\t\t\t\t)}\n\t\t\t\u003c/Static\u003e\n\n\t\t\t{/* This part keeps updating as state changes */}\n\t\t\t\u003cBox marginTop={1}\u003e\n\t\t\t\t\u003cText dimColor\u003eCompleted tests: {tests.length}\u003c/Text\u003e\n\t\t\t\u003c/Box\u003e\n\t\t\u003c/\u003e\n\t);\n};\n\nrender(\u003cExample /\u003e);\n```\n\n\u003e [!NOTE]\n\u003e `\u003cStatic\u003e` only renders new items in the `items` prop and ignores items\nthat were previously rendered. This means that when you add new items to the `items`\narray, changes you make to previous items will not trigger a rerender.\n\nSee [examples/static](examples/static/static.tsx) for an example usage of `\u003cStatic\u003e` component.\n\n#### items\n\nType: `Array`\n\nArray of items of any type to render using the function you pass as a component child.\n\n#### style\n\nType: `object`\n\nStyles to apply to a container of child elements.\nSee [`\u003cBox\u003e`](#box) for supported properties.\n\n```jsx\n\u003cStatic items={...} style={{padding: 1}}\u003e\n\t{...}\n\u003c/Static\u003e\n```\n\n#### children(item)\n\nType: `Function`\n\nFunction that is called to render every item in the `items` array.\nThe first argument is the item itself, and the second argument is the index of that item in the\n`items` array.\n\nNote that a `key` must be assigned to the root component.\n\n```jsx\n\u003cStatic items={['a', 'b', 'c']}\u003e\n\t{(item, index) =\u003e {\n\t\t// This function is called for every item in ['a', 'b', 'c']\n\t\t// `item` is 'a', 'b', 'c'\n\t\t// `index` is 0, 1, 2\n\t\treturn (\n\t\t\t\u003cBox key={index}\u003e\n\t\t\t\t\u003cText\u003eItem: {item}\u003c/Text\u003e\n\t\t\t\u003c/Box\u003e\n\t\t);\n\t}}\n\u003c/Static\u003e\n```\n\n### `\u003cTransform\u003e`\n\nTransform a string representation of React components before they're written to output.\nFor example, you might want to apply a [gradient to text](https://github.com/sindresorhus/ink-gradient), [add a clickable link](https://github.com/sindresorhus/ink-link), or [create some text effects](https://github.com/sindresorhus/ink-big-text).\nThese use cases can't accept React nodes as input; they expect a string.\nThat's what the `\u003cTransform\u003e` component does: it gives you an output string of its child components and lets you transform it in any way.\n\n\u003e [!NOTE]\n\u003e `\u003cTransform\u003e` must be applied only to `\u003cText\u003e` children components and shouldn't change the dimensions of the output; otherwise, the layout will be incorrect.\n\n\u003e [!IMPORTANT]\n\u003e When children use `\u003cText\u003e` styling props (e.g. `color`, `bold`), the string passed to `transform` will contain [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). If your transform manipulates whitespace or does string operations like `.trim()`, you may need to use ANSI-aware methods (e.g. from [`slice-ansi`](https://github.com/chalk/slice-ansi) or [`strip-ansi`](https://github.com/chalk/strip-ansi)).\n\n```jsx\nimport {render, Transform} from 'ink';\n\nconst Example = () =\u003e (\n\t\u003cTransform transform={output =\u003e output.toUpperCase()}\u003e\n\t\t\u003cText\u003eHello World\u003c/Text\u003e\n\t\u003c/Transform\u003e\n);\n\nrender(\u003cExample /\u003e);\n```\n\nSince the `transform` function converts all characters to uppercase, the final output rendered to the terminal will be \"HELLO WORLD\", not \"Hello World\".\n\nWhen the output wraps to multiple lines, it can be helpful to know which line is being processed.\n\nFor example, to implement a hanging indent component, you can indent all the lines except for the first.\n\n```jsx\nimport {render, Transform} from 'ink';\n\nconst HangingIndent = ({indent = 4, children}) =\u003e (\n\t\u003cTransform\n\t\ttransform={(line, index) =\u003e\n\t\t\tindex === 0 ? line : ' '.repeat(indent) + line\n\t\t}\n\t\u003e\n\t\t{children}\n\t\u003c/Transform\u003e\n);\n\nconst text =\n\t'WHEN I WROTE the following pages, or rather the bulk of them, ' +\n\t'I lived alone, in the woods, a mile from any neighbor, in a ' +\n\t'house which I had built myself, on the shore of Walden Pond, ' +\n\t'in Concord, Massachusetts, and earned my living by the labor ' +\n\t'of my hands only. I lived there two years and two months. At ' +\n\t'present I am a sojourner in civilized life again.';\n\nrender(\n\t\u003cHangingIndent indent={4}\u003e\n\t\t{text}\n\t\u003c/HangingIndent\u003e\n);\n```\n\n#### transform(outputLine, index)\n\nType: `Function`\n\nFunction that transforms children output.\nIt accepts children and must return transformed children as well.\n\n##### children\n\nType: `string`\n\nOutput of child components.\n\n##### index\n\nType: `number`\n\nThe zero-indexed line number of the line that's currently being transformed.\n\n## Hooks\n\n### useInput(inputHandler, options?)\n\nA React hook that returns `void` and handles user input.\nIt's a more convenient alternative to using `useStdin` and listening for `data` events.\nThe callback you pass to `useInput` is called for each character when the user enters any input.\nHowever, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.\nYou can find a full example of using `useInput` at [examples/use-input](examples/use-input/use-input.tsx).\n\n```jsx\nimport {useInput} from 'ink';\n\nconst UserInput = () =\u003e {\n\tuseInput((input, key) =\u003e {\n\t\tif (input === 'q') {\n\t\t\t// Exit program\n\t\t}\n\n\t\tif (key.leftArrow) {\n\t\t\t// Left arrow key pressed\n\t\t}\n\t});\n\n\treturn …\n};\n```\n\n#### inputHandler(input, key)\n\nType: `Function`\n\nThe handler function that you pass to `useInput` receives two arguments:\n\n##### input\n\nType: `string`\n\nThe input that the program received.\n\n##### key\n\nType: `object`\n\nHandy information about a key that was pressed.\n\n###### key.leftArrow\n\n###### key.rightArrow\n\n###### key.upArrow\n\n###### key.downArrow\n\nType: `boolean`\\\nDefault: `false`\n\nIf an arrow key was pressed, the corresponding property will be `true`.\nFor example, if the user presses the left arrow key, `key.leftArrow` equals `true`.\n\n###### key.return\n\nType: `boolean`\\\nDefault: `false`\n\nReturn (Enter) key was pressed.\n\n###### key.escape\n\nType: `boolean`\\\nDefault: `false`\n\nEscape key was pressed.\n\n###### key.ctrl\n\nType: `boolean`\\\nDefault: `false`\n\nCtrl key was pressed.\n\n###### key.shift\n\nType: `boolean`\\\nDefault: `false`\n\nShift key was pressed.\n\n###### key.tab\n\nType: `boolean`\\\nDefault: `false`\n\nTab key was pressed.\n\n###### key.backspace\n\nType: `boolean`\\\nDefault: `false`\n\nBackspace key was pressed.\n\n###### key.delete\n\nType: `boolean`\\\nDefault: `false`\n\nDelete key was pressed.\n\n###### key.pageDown\n\n###### key.pageUp\n\nType: `boolean`\\\nDefault: `false`\n\nIf the Page Up or Page Down key was pressed, the corresponding property will be `true`.\nFor example, if the user presses Page Down, `key.pageDown` equals `true`.\n\n###### key.home\n\n###### key.end\n\nType: `boolean`\\\nDefault: `false`\n\nIf the Home or End key was pressed, the corresponding property will be `true`.\nFor example, if the user presses End, `key.end` equals `true`.\n\n###### key.meta\n\nType: `boolean`\\\nDefault: `false`\n\n[Meta key](https://en.wikipedia.org/wiki/Meta_key) was pressed.\n\n###### key.super\n\nType: `boolean`\\\nDefault: `false`\n\nSuper key (Cmd on macOS, Win on Windows) was pressed. Requires [kitty keyboard protocol](#kittykeyboard).\n\n###### key.hyper\n\nType: `boolean`\\\nDefault: `false`\n\nHyper key was pressed. Requires [kitty keyboard protocol](#kittykeyboard).\n\n###### key.capsLock\n\nType: `boolean`\\\nDefault: `false`\n\nCaps Lock was active. Requires [kitty keyboard protocol](#kittykeyboard).\n\n###### key.numLock\n\nType: `boolean`\\\nDefault: `false`\n\nNum Lock was active. Requires [kitty keyboard protocol](#kittykeyboard).\n\n###### key.eventType\n\nType: `'press' | 'repeat' | 'release'`\\\nDefault: `undefined`\n\nThe type of key event. Only available with [kitty keyboard protocol](#kittykeyboard). Without the protocol, this property is `undefined`.\n\n#### options\n\nType: `object`\n\n##### isActive\n\nType: `boolean`\\\nDefault: `true`\n\nEnable or disable capturing of user input.\nUseful when there are multiple `useInput` hooks used at once to avoid handling the same input several times.\n\n### usePaste(handler, options?)\n\nA React hook that calls `handler` whenever the user pastes text. Bracketed paste mode (`\\x1b[?2004h`) is automatically enabled while the hook is active, so pasted text arrives as a single string rather than being misinterpreted as individual key presses.\n\n`usePaste` and `useInput` can be used together in the same component. They operate on separate event channels, so paste content is never forwarded to `useInput` handlers when `usePaste` is active.\n\n```jsx\nimport {useInput, usePaste} from 'ink';\n\nconst MyInput = () =\u003e {\n\tuseInput((input, key) =\u003e {\n\t\t// Only receives typed characters and key events, not pasted text.\n\t\tif (key.return) {\n\t\t\t// Submit\n\t\t}\n\t});\n\n\tusePaste((text) =\u003e {\n\t\t// Receives the full pasted string, including newlines.\n\t\tconsole.log('Pasted:', text);\n\t});\n\n\treturn …\n};\n```\n\n#### handler(text)\n\nType: `Function`\n\nCalled with the full pasted string whenever the user pastes text. The string is delivered verbatim — newlines, escape sequences, and other special characters are preserved exactly as pasted.\n\n##### text\n\nType: `string`\n\nThe pasted text.\n\n#### options\n\nType: `object`\n\n##### isActive\n\nType: `boolean`\\\nDefault: `true`\n\nEnable or disable the paste handler. Useful when multiple components use `usePaste` and only one should be active at a time.\n\n### useApp()\n\nA React hook that returns app lifecycle methods.\n\n#### exit(errorOrResult?)\n\nType: `Function`\n\nExit (unmount) the whole Ink app.\n\n##### errorOrResult\n\nType: `Error | unknown`\n\nOptional value that controls how [`waitUntilExit`](#waituntilexit) settles:\n- `exit()` resolves with `undefined`.\n- `exit(error)` rejects when `error` is an `Error`.\n- `exit(value)` resolves with `value`.\n\n```js\nimport {useEffect} from 'react';\nimport {useApp} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {exit} = useApp();\n\n\t// Exit the app after 5 seconds\n\tuseEffect(() =\u003e {\n\t\tsetTimeout(() =\u003e {\n\t\t\texit();\n\t\t}, 5000);\n\t}, [exit]);\n\n\treturn …\n};\n```\n\n#### waitUntilRenderFlush()\n\nType: `Function`\n\nReturns a promise that settles after pending render output is flushed to stdout.\n\n```js\nimport {useEffect} from 'react';\nimport {useApp} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {waitUntilRenderFlush} = useApp();\n\n\tuseEffect(() =\u003e {\n\t\tvoid (async () =\u003e {\n\t\t\tawait waitUntilRenderFlush();\n\t\t\trunNextCommand();\n\t\t})();\n\t}, [waitUntilRenderFlush]);\n\n\treturn …;\n};\n```\n\n### useStdin()\n\nA React hook that returns the stdin stream and stdin-related utilities.\n\n#### stdin\n\nType: `stream.Readable`\\\nDefault: `process.stdin`\n\nThe stdin stream passed to `render()` in `options.stdin`, or `process.stdin` by default.\nUseful if your app needs to handle user input.\n\n```js\nimport {useStdin} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {stdin} = useStdin();\n\n\treturn …\n};\n```\n\n#### isRawModeSupported\n\nType: `boolean`\n\nA boolean flag determining if the current `stdin` supports `setRawMode`.\nA component using `setRawMode` might want to use `isRawModeSupported` to nicely fall back in environments where raw mode is not supported.\n\n```jsx\nimport {useStdin} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {isRawModeSupported} = useStdin();\n\n\treturn isRawModeSupported ? (\n\t\t\u003cMyInputComponent /\u003e\n\t) : (\n\t\t\u003cMyComponentThatDoesntUseInput /\u003e\n\t);\n};\n```\n\n#### setRawMode(isRawModeEnabled)\n\nType: `function`\n\n##### isRawModeEnabled\n\nType: `boolean`\n\nSee [`setRawMode`](https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode).\nInk exposes this function to be able to handle \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eC\u003c/kbd\u003e, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`.\n\n**Warning:** This function will throw unless the current `stdin` supports `setRawMode`. Use [`isRawModeSupported`](#israwmodesupported) to detect `setRawMode` support.\n\n```js\nimport {useStdin} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {setRawMode} = useStdin();\n\n\tuseEffect(() =\u003e {\n\t\tsetRawMode(true);\n\n\t\treturn () =\u003e {\n\t\t\tsetRawMode(false);\n\t\t};\n\t});\n\n\treturn …\n};\n```\n\n### useStdout()\n\nA React hook that returns the stdout stream where Ink renders your app and stdout-related utilities.\n\n#### stdout\n\nType: `stream.Writable`\\\nDefault: `process.stdout`\n\n```js\nimport {useStdout} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {stdout} = useStdout();\n\n\treturn …\n};\n```\n\n#### write(data)\n\nWrite any string to stdout while preserving Ink's output.\nIt's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two.\nIt's similar to `\u003cStatic\u003e`, except it can't accept components; it only works with strings.\n\n##### data\n\nType: `string`\n\nData to write to stdout.\n\n```js\nimport {useStdout} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {write} = useStdout();\n\n\tuseEffect(() =\u003e {\n\t\t// Write a single message to stdout, above Ink's output\n\t\twrite('Hello from Ink to stdout\\n');\n\t}, []);\n\n\treturn …\n};\n```\n\nSee additional usage example in [examples/use-stdout](examples/use-stdout/use-stdout.tsx).\n\n### useBoxMetrics(ref)\n\nA React hook that returns the current layout metrics for a tracked box element.\nIt updates when layout changes (for example terminal resize, sibling/content changes, or position changes).\n\nUse `hasMeasured` to detect when the currently tracked element has been measured.\n\n#### ref\n\nType: `React.RefObject\u003cDOMElement\u003e`\n\nA ref to the `\u003cBox\u003e` element to track.\n\n```jsx\nimport {useRef} from 'react';\nimport {Box, Text, useBoxMetrics} from 'ink';\n\nconst Example = () =\u003e {\n\tconst ref = useRef(null);\n\tconst {width, height, left, top, hasMeasured} = useBoxMetrics(ref);\n\n\treturn (\n\t\t\u003cBox ref={ref}\u003e\n\t\t\t\u003cText\u003e\n\t\t\t\t{hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}\n\t\t\t\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\t);\n};\n```\n\n#### width\n\nType: `number`\n\nElement width.\n\n#### height\n\nType: `number`\n\nElement height.\n\n#### left\n\nType: `number`\n\nDistance from the left edge of the parent.\n\n#### top\n\nType: `number`\n\nDistance from the top edge of the parent.\n\n#### hasMeasured\n\nType: `boolean`\n\nWhether the currently tracked element has been measured.\n\n\u003e [!NOTE]\n\u003e The hook returns `{width: 0, height: 0, left: 0, top: 0}` until the first layout pass completes. It also returns zeros when the tracked ref is detached.\n\n### useStderr()\n\nA React hook that returns the stderr stream and stderr-related utilities.\n\n#### stderr\n\nType: `stream.Writable`\\\nDefault: `process.stderr`\n\nStderr stream.\n\n```js\nimport {useStderr} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {stderr} = useStderr();\n\n\treturn …\n};\n```\n\n#### write(data)\n\nWrite any string to stderr while preserving Ink's output.\n\nIt's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two.\nIt's similar to `\u003cStatic\u003e`, except it can't accept components; it only works with strings.\n\n##### data\n\nType: `string`\n\nData to write to stderr.\n\n```js\nimport {useStderr} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {write} = useStderr();\n\n\tuseEffect(() =\u003e {\n\t\t// Write a single message to stderr, above Ink's output\n\t\twrite('Hello from Ink to stderr\\n');\n\t}, []);\n\n\treturn …\n};\n```\n\n### useWindowSize()\n\nA React hook that returns the current terminal dimensions and re-renders the component whenever the terminal is resized.\n\n```js\nimport {Text, useWindowSize} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {columns, rows} = useWindowSize();\n\n\treturn \u003cText\u003e{columns}x{rows}\u003c/Text\u003e;\n};\n```\n\n#### columns\n\nType: `number`\n\nNumber of columns (horizontal character cells).\n\n#### rows\n\nType: `number`\n\nNumber of rows (vertical character cells).\n\n### useFocus(options?)\n\nA React hook that returns focus state and focus controls for the current component.\nA component that uses the `useFocus` hook becomes \"focusable\" to Ink, so when the user presses \u003ckbd\u003eTab\u003c/kbd\u003e, Ink will switch focus to this component.\nIf there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.\nThis hook returns an object with an `isFocused` boolean property, which determines whether this component is focused.\n\n#### options\n\n##### autoFocus\n\nType: `boolean`\\\nDefault: `false`\n\nAuto-focus this component if there's no active (focused) component right now.\n\n##### isActive\n\nType: `boolean`\\\nDefault: `true`\n\nEnable or disable this component's focus, while still maintaining its position in the list of focusable components.\nThis is useful for inputs that are temporarily disabled.\n\n##### id\n\nType: `string`\\\nRequired: `false`\n\nSet a component's focus ID, which can be used to programmatically focus the component. This is useful for large interfaces with many focusable elements to avoid having to cycle through all of them.\n\n```jsx\nimport {render, useFocus, Text} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {isFocused} = useFocus();\n\n\treturn \u003cText\u003e{isFocused ? 'I am focused' : 'I am not focused'}\u003c/Text\u003e;\n};\n\nrender(\u003cExample /\u003e);\n```\n\nSee example in [examples/use-focus](examples/use-focus/use-focus.tsx) and [examples/use-focus-with-id](examples/use-focus-with-id/use-focus-with-id.tsx).\n\n### useFocusManager()\n\nA React hook that returns methods to manage focus across focusable components.\n\n#### enableFocus()\n\nEnable focus management for all components.\n\n\u003e [!NOTE]\n\u003e You don't need to call this method manually unless you've disabled focus management. Focus management is enabled by default.\n\n```js\nimport {useFocusManager} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {enableFocus} = useFocusManager();\n\n\tuseEffect(() =\u003e {\n\t\tenableFocus();\n\t}, []);\n\n\treturn …\n};\n```\n\n#### disableFocus()\n\nDisable focus management for all components.\nThe currently active component (if there's one) will lose its focus.\n\n```js\nimport {useFocusManager} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {disableFocus} = useFocusManager();\n\n\tuseEffect(() =\u003e {\n\t\tdisableFocus();\n\t}, []);\n\n\treturn …\n};\n```\n\n#### focusNext()\n\nSwitch focus to the next focusable component.\nIf there's no active component right now, focus will be given to the first focusable component.\nIf the active component is the last in the list of focusable components, focus will be switched to the first focusable component.\n\n\u003e [!NOTE]\n\u003e Ink calls this method when user presses \u003ckbd\u003eTab\u003c/kbd\u003e.\n\n```js\nimport {useFocusManager} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {focusNext} = useFocusManager();\n\n\tuseEffect(() =\u003e {\n\t\tfocusNext();\n\t}, []);\n\n\treturn …\n};\n```\n\n#### focusPrevious()\n\nSwitch focus to the previous focusable component.\nIf there's no active component right now, focus will be given to the first focusable component.\nIf the active component is the first in the list of focusable components, focus will be switched to the last focusable component.\n\n\u003e [!NOTE]\n\u003e Ink calls this method when user presses \u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eTab\u003c/kbd\u003e.\n\n```js\nimport {useFocusManager} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {focusPrevious} = useFocusManager();\n\n\tuseEffect(() =\u003e {\n\t\tfocusPrevious();\n\t}, []);\n\n\treturn …\n};\n```\n\n#### focus(id)\n\n##### id\n\nType: `string`\n\nSwitch focus to the component with the given [`id`](#id).\nIf there's no component with that ID, focus is not changed.\n\n```js\nimport {useFocusManager, useInput} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {focus} = useFocusManager();\n\n\tuseInput(input =\u003e {\n\t\tif (input === 's') {\n\t\t\t// Focus the component with focus ID 'someId'\n\t\t\tfocus('someId');\n\t\t}\n\t});\n\n\treturn …\n};\n```\n\n#### activeId\n\nType: `string | undefined`\n\nThe ID of the currently focused component, or `undefined` if no component is focused.\n\n```js\nimport {Text, useFocusManager} from 'ink';\n\nconst Example = () =\u003e {\n\tconst {activeId} = useFocusManager();\n\n\treturn \u003cText\u003eFocused: {activeId ?? 'none'}\u003c/Text\u003e;\n};\n```\n\n### useCursor()\n\nA React hook that returns methods to control the terminal cursor position after each render.\nThis is essential for IME (Input Method Editor) support, where the composing character is displayed at the cursor location.\n\n```jsx\nimport {useState} from 'react';\nimport {Box, Text, useCursor} from 'ink';\nimport stringWidth from 'string-width';\n\nconst TextInput = () =\u003e {\n\tconst [text, setText] = useState('');\n\tconst {setCursorPosition} = useCursor();\n\n\tconst prompt = '\u003e ';\n\tsetCursorPosition({x: stringWidth(prompt + text), y: 1});\n\n\treturn (\n\t\t\u003cBox flexDirection=\"column\"\u003e\n\t\t\t\u003cText\u003eType here:\u003c/Text\u003e\n\t\t\t\u003cText\u003e{prompt}{text}\u003c/Text\u003e\n\t\t\u003c/Box\u003e\n\t);\n};\n```\n\n#### setCursorPosition(position)\n\nSet the cursor position relative to the Ink output. Pass `undefined` to hide the cursor.\n\n##### position\n\nType: `object | undefined`\n\nUse [`string-width`](https://github.com/sindresorhus/string-width) to calculate `x` for strings containing wide characters (CJK, emoji).\n\nSee a full example at [examples/cursor-ime](examples/cursor-ime/cursor-ime.tsx).\n\n###### x\n\nType: `number`\n\nColumn position (0-based).\n\n###### y\n\nType: `number`\n\nRow position from the top of the Ink output (0 = first line).\n\n### useIsScreenReaderEnabled()\n\nA React hook that returns whether a screen reader is enabled.\nThis is useful when you want to render different output for screen readers.\n\n```jsx\nimport {useIsScreenReaderEnabled, Text} from 'ink';\n\nconst Example = () =\u003e {\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\treturn (\n\t\t\u003cText\u003e\n\t\t\t{isScreenReaderEnabled\n\t\t\t\t? 'Screen reader is enabled'\n\t\t\t\t: 'Screen reader is disabled'}\n\t\t\u003c/Text\u003e\n\t);\n};\n```\n\n## API\n\n#### render(tree, options?)\n\nReturns: [`Instance`](#instance)\n\nMount a component and render the output.\n\n##### tree\n\nType: `ReactNode`\n\n##### options\n\nType: `object`\n\n###### stdout\n\nType: `stream.Writable`\\\nDefault: `process.stdout`\n\nOutput stream where the app will be rendered.\n\n###### stdin\n\nType: `stream.Readable`\\\nDefault: `process.stdin`\n\nInput stream where app will listen for input.\n\n###### stderr\n\nType: `stream.Writable`\\\nDefault: `process.stderr`\n\nError stream.\n\n###### exitOnCtrlC\n\nType: `boolean`\\\nDefault: `true`\n\nConfigure whether Ink should listen for Ctrl+C keyboard input and exit the app.\nThis is needed in case `process.stdin` is in [raw mode](https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode), because then Ctrl+C is ignored by default and the process is expected to handle it manually.\n\n###### patchConsole\n\nType: `boolean`\\\nDefault: `true`\n\nPatch console methods to ensure console output doesn't mix with Ink's output.\nWhen any of the `console.*` methods are called (like `console.log()`), Ink intercepts their output, clears the main output, renders output from the console method, and then rerenders the main output again.\nThat way, both are visible and don't overlap each other.\n\nThis functionality is powered by [patch-console](https://github.com/vadimdemedes/patch-console), so if you need to disable Ink's interception of output but want to build something custom, you can use that.\n\n###### onRender\n\nType: `({renderTime: number}) =\u003e void`\\\nDefault: `undefined`\n\nRuns the given callback after each render and re-render with render metrics.\nThis callback runs after Ink commits a frame, but it does not wait for `stdout`/`stderr` stream callbacks.\nTo run code after output is flushed, use [`waitUntilRenderFlush()`](#waituntilrenderflush).\n\n###### isScreenReaderEnabled\n\nType: `boolean`\\\nDefault: `process.env['INK_SCREEN_READER'] === 'true'`\n\nEnable screen reader support. See [Screen Reader Support](#screen-reader-support).\n\n###### debug\n\nType: `boolean`\\\nDefault: `false`\n\nIf `true`, each update will be rendered as separate output, without replacing the previous one.\n\n###### maxFps\n\nType: `number`\\\nDefault: `30`\n\nMaximum frames per second for render updates.\nThis controls how frequently the UI can update to prevent excessive re-rendering.\nHigher values allow more frequent updates but may impact performance.\nSetting it to a lower value may be useful for components that update very frequently, to reduce CPU usage.\n\n###### incrementalRendering\n\nType: `boolean`\\\nDefault: `false`\n\nEnable incremental rendering mode which only updates changed lines instead of redrawing the entire output.\nThis can reduce flickering and improve performance for frequently updating UIs.\n\n###### concurrent\n\nType: `boolean`\\\nDefault: `false`\n\nEnable React Concurrent Rendering mode.\n\nWhen enabled:\n- Suspense boundaries work correctly with async data fetching\n- `useTransition` and `useDeferredValue` hooks are fully functional\n- Updates can be interrupted for higher priority work\n\n```jsx\nrender(\u003cMyApp /\u003e, {concurrent: true});\n```\n\n\u003e [!NOTE]\n\u003e Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. The `concurrent` option only takes effect on the first render for a given stdout. If you need to change the rendering mode, call `unmount()` first.\n\n###### interactive\n\nType: `boolean`\\\nDefault: `true` (`false` if in CI (detected via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) or `stdout.isTTY` is falsy)\n\nOverride automatic interactive mode detection.\n\nBy default, Ink detects whether the environment is interactive based on CI detection and `stdout.isTTY`. When non-interactive, Ink skips terminal-specific features like ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection. Only the final frame of non-static output is written at unmount.\n\nMost users should not need to set this option. Use it when you have your own \"interactive\" detection logic that differs from the built-in behavior.\n\n```jsx\n// Use your own detection logic\nconst isInteractive = myCustomDetection();\nrender(\u003cMyApp /\u003e, {interactive: isInteractive});\n```\n\n###### kittyKeyboard\n\nType: `object`\\\nDefault: `undefined`\n\nEnable the [kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) for enhanced keyboard input handling. When enabled, terminals that support the protocol will report additional key information including `super`, `hyper`, `capsLock`, `numLock` modifiers and `eventType` (press/repeat/release).\n\n```jsx\nimport {render} from 'ink';\n\nrender(\u003cMyApp /\u003e, {kittyKeyboard: {mode: 'auto'}});\n```\n\n```jsx\nimport {render} from 'ink';\n\nrender(\u003cMyApp /\u003e, {\n\tkittyKeyboard: {\n\t\tmode: 'enabled',\n\t\tflags: ['disambiguateEscapeCodes', 'reportEventTypes'],\n\t},\n});\n```\n\n**kittyKeyboard.mode**\n\nType: `'auto' | 'enabled' | 'disabled'`\\\nDefault: `'auto'`\n\n- `'auto'`: Detect terminal support using a heuristic precheck (known terminals like kitty, WezTerm, Ghostty) followed by a protocol query confirmation (`CSI ? u`). The protocol is only enabled if the terminal responds to the query within a short timeout.\n- `'enabled'`: Force enable the protocol. Both stdin and stdout must be TTYs.\n- `'disabled'`: Never enable the protocol.\n\n**kittyKeyboard.flags**\n\nType: `string[]`\\\nDefault: `['disambiguateEscapeCodes']`\n\nProtocol flags to request from the terminal. Pass an array of flag name strings.\n\nAvailable flags:\n- `'disambiguateEscapeCodes'` - Disambiguate escape codes\n- `'reportEventTypes'` - Report key press, repeat, and release events\n- `'reportAlternateKeys'` - Report alternate key encodings\n- `'reportAllKeysAsEscapeCodes'` - Report all keys as escape codes\n- `'reportAssociatedText'` - Report associated text with key events\n\n**Behavior notes**\n\nWhen the kitty keyboard protocol is enabled, input handling changes in several ways:\n\n- **Non-printable keys produce empty input.** Keys like function keys (F1-F35), modifier-only keys (Shift, Control, Super), media keys, Caps Lock, Print Screen, and similar keys will not produce any text in the `input` parameter of `useInput`. They can still be detected via the `key` object properties.\n- **Ctrl+letter shortcuts work as expected.** When the terminal sends `Ctrl+letter` as codepoint 1-26 (the kitty CSI-u alternate form), `input` is set to the letter name (e.g. `'c'` for `Ctrl+C`) and `key.ctrl` is `true`. This ensures `exitOnCtrlC` and custom `Ctrl+letter` handlers continue to work regardless of which codepoint form the terminal uses.\n- **Key disambiguation.** The protocol allows the terminal to distinguish between keys that normally produce the same escape sequence. For example:\n  - `Ctrl+I` vs `Tab` - without the protocol, both produce the same byte (`\\x09`). With the protocol, they are reported as distinct keys.\n  - `Shift+Enter` vs `Enter` - the shift modifier is correctly reported.\n  - `Escape` key vs `Ctrl+[` - these are disambiguated.\n- **Event types.** With the `reportEventTypes` flag, key press, repeat, and release events are distinguished via `key.eventType`.\n\n#### renderToString(tree, options?)\n\nReturns: `string`\n\nRender a React element to a string synchronously. Unlike `render()`, this function does not write to stdout, does not set up any terminal event listeners, and returns the rendered output as a string.\n\nUseful for generating documentation, writing output to files, testing, or any scenario where you need the rendered output as a string without starting a persistent terminal application.\n\n```jsx\nimport {renderToString, Text, Box} from 'ink';\n\nconst output = renderToString(\n\t\u003cBox padding={1}\u003e\n\t\t\u003cText color=\"green\"\u003eHello World\u003c/Text\u003e\n\t\u003c/Box\u003e,\n);\n\nconsole.log(output);\n```\n\n**Notes:**\n\n- Terminal-specific hooks (`useInput`, `useStdin`, `useStdout`, `useStderr`, `useWindowSize`, `useApp`, `useFocus`, `useFocusManager`) return default no-op values since there is no terminal session. They will not throw, but they will not function as in a live terminal.\n- `useEffect` callbacks will execute during rendering (due to synchronous rendering mode), but state updates they trigger will not affect the returned output, which reflects the initial render.\n- `useLayoutEffect` callbacks fire synchronously during commit, so state updates they trigger **will** be reflected in the output.\n- The `\u003cStatic\u003e` component is supported — its output is prepended to the dynamic output.\n- If a component throws during rendering, the error is propagated to the caller after cleanup.\n\n##### tree\n\nType: `ReactNode`\n\n##### options\n\nType: `object`\n\n###### columns\n\nType: `number`\\\nDefault: `80`\n\nWidth of the virtual terminal in columns. Controls where text wrapping occurs.\n\n```jsx\nconst output = renderToString(\u003cText\u003e{'A'.repeat(100)}\u003c/Text\u003e, {\n\tcolumns: 40,\n});\n// Text wraps at 40 columns\n```\n\n#### Instance\n\nThis is the object that `render()` returns.\n\n##### rerender(tree)\n\nReplace the previous root node with a new one or update the props of the current root node.\n\n###### tree\n\nType: `ReactNode`\n\n```jsx\n// Update props of the root node\nconst {rerender} = render(\u003cCounter count={1} /\u003e);\nrerender(\u003cCounter count={2} /\u003e);\n\n// Replace root node\nconst {rerender} = render(\u003cOldCounter /\u003e);\nrerender(\u003cNewCounter /\u003e);\n```\n\n##### unmount()\n\nManually unmount the whole Ink app.\n\n```jsx\nconst {unmount} = render(\u003cMyApp /\u003e);\nunmount();\n```\n\n##### waitUntilExit()\n\nReturns a promise that settles when the app is unmounted.\n\nIt resolves with the value passed to `exit(value)` and rejects with the error passed to `exit(error)`.\nWhen `unmount()` is called manually, it settles after unmount-related stdout writes complete.\n\n```jsx\nconst {unmount, waitUntilExit} = render(\u003cMyApp /\u003e);\n\nsetTimeout(unmount, 1000);\n\nawait waitUntilExit(); // resolves after `unmount()` is called\n```\n\n##### waitUntilRenderFlush()\n\nReturns a promise that settles after pending render output is flushed to stdout.\n\nUseful when you need to run code only after a frame is written:\n\n```jsx\nconst {rerender, waitUntilRenderFlush} = render(\u003cMyApp step=\"loading\" /\u003e);\n\nrerender(\u003cMyApp step=\"ready\" /\u003e);\nawait waitUntilRenderFlush(); // output for \"ready\" is flushed\n\nrunNextCommand();\n```\n\n##### cleanup()\n\nDelete the internal Ink instance associated with the current `stdout`.\nThis is mostly useful for advanced cases (for example, tests) where you need `render()` to create a fresh instance for the same stream.\nThis does not unmount the current app.\n\n##### clear()\n\nClear output.\n\n```jsx\nconst {clear} = render(\u003cMyApp /\u003e);\nclear();\n```\n\n#### measureElement(ref)\n\nMeasure the dimensions of a particular `\u003cBox\u003e` element.\nReturns an object with `width` and `height` properties.\nThis function is useful when your component needs to know the amount of available space it has. You can use it when you need to change the layout based on the length of its content.\n\n\u003e [!NOTE]\n\u003e `measureElement()` returns `{width: 0, height: 0}` when called during render (before layout is calculated). Call it from post-render code, such as `useEffect`, `useLayoutEffect`, input handlers, or timer callbacks. When content changes, pass the relevant dependency to your effect so it re-measures after each update.\n\n##### ref\n\nType: `MutableRef`\n\nA reference to a `\u003cBox\u003e` element captured with the `ref` property.\nSee [Refs](https://reactjs.org/docs/refs-and-the-dom.html) for more information on how to capture references.\n\n```jsx\nimport {render, measureElement, Box, Text} from 'ink';\n\nconst Example = () =\u003e {\n\tconst ref = useRef();\n\n\tuseEffect(() =\u003e {\n\t\tconst {width, height} = measureElement(ref.current);\n\t\t// width = 100, height = 1\n\t}, []);\n\n\treturn (\n\t\t\u003cBox width={100}\u003e\n\t\t\t\u003cBox ref={ref}\u003e\n\t\t\t\t\u003cText\u003eThis box will stretch to 100 width\u003c/Text\u003e\n\t\t\t\u003c/Box\u003e\n\t\t\u003c/Box\u003e\n\t);\n};\n\nrender(\u003cExample /\u003e);\n```\n\n## Testing\n\nInk components are simple to test with [ink-testing-library](https://github.com/vadimdemedes/ink-testing-library).\nHere's a simple example that checks how the component is rendered:\n\n```jsx\nimport React from 'react';\nimport {Text} from 'ink';\nimport {render} from 'ink-testing-library';\n\nconst Test = () =\u003e \u003cText\u003eHello World\u003c/Text\u003e;\nconst {lastFrame} = render(\u003cTest /\u003e);\n\nlastFrame() === 'Hello World'; //=\u003e true\n```\n\nCheck out [ink-testing-library](https://github.com/vadimdemedes/ink-testing-library) for more examples and full documentation.\n\n## Using React Devtools\n\n![](media/devtools.jpg)\n\nInk supports [React Devtools](https://github.com/facebook/react/tree/master/packages/react-devtools) out of the box. To enable integration with React Devtools in your Ink-based CLI, first ensure you have installed the optional `react-devtools-core` dependency, and then run your app with the `DEV=true` environment variable:\n\n```sh\nDEV=true my-cli\n```\n\nThen, start React Devtools itself:\n\n```sh\nnpx react-devtools\n```\n\nAfter it starts, you should see the component tree of your CLI.\nYou can even inspect and change the props of components, and see the results immediately in the CLI, without restarting it.\n\n\u003e [!NOTE]\n\u003e You must manually quit your CLI via \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eC\u003c/kbd\u003e after you're done testing.\n\n## Screen Reader Support\n\nInk has basic support for screen readers.\n\nTo enable it, you can either pass the `isScreenReaderEnabled` option to the `render` function or set the `INK_SCREEN_READER` environment variable to `true`.\n\nInk implements a small subset of functionality from the [ARIA specification](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA).\n\n```jsx\nrender(\u003cMyApp /\u003e, {isScreenReaderEnabled: true});\n```\n\nWhen screen reader support is enabled, Ink will try its best to generate a screen-reader-friendly output.\n\nFor example, for this code:\n\n```jsx\n\u003cBox aria-role=\"checkbox\" aria-state={{checked: true}}\u003e\n\t\u003cText\u003eAccept terms and conditions\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\nInk will generate the following output for screen readers:\n\n```\n(checked) checkbox: Accept terms and conditions\n```\n\nYou can also provide a custom label for screen readers if you want to render something different for them.\n\nFor example, if you are building a progress bar, you can use `aria-label` to provide a more descriptive label for screen readers.\n\n```jsx\n\u003cBox\u003e\n\t\u003cBox width=\"50%\" height={1} backgroundColor=\"green\" /\u003e\n\t\u003cText aria-label=\"Progress: 50%\"\u003e50%\u003c/Text\u003e\n\u003c/Box\u003e\n```\n\nIn the example above, the screen reader will read \"Progress: 50%\" instead of \"50%\".\n\n### `aria-label`\n\nType: `string`\n\nA label for the element for screen readers.\n\n### `aria-hidden`\n\nType: `boolean`\\\nDefault: `false`\n\nHide the element from screen readers.\n\n##### aria-role\n\nType: `string`\n\nThe role of the element.\n\nSupported values:\n- `button`\n- `checkbox`\n- `radio`\n- `radiogroup`\n- `list`\n- `listitem`\n- `menu`\n- `menuitem`\n- `progressbar`\n- `tab`\n- `tablist`\n- `timer`\n- `toolbar`\n- `table`\n\n##### aria-state\n\nType: `object`\n\nThe state of the element.\n\nSupported values:\n- `checked` (boolean)\n- `disabled` (boolean)\n- `expanded` (boolean)\n- `selected` (boolean)\n\n## Creating Components\n\nWhen building custom components, it's important to keep accessibility in mind. While Ink provides the building blocks, ensuring your components are accessible will make your CLIs usable by a wider audience.\n\n### General Principles\n\n- **Provide screen reader-friendly output:** Use the `useIsScreenReaderEnabled` hook to detect if a screen reader is active. You can then render more descriptive output for screen reader users.\n- **Leverage ARIA props:** For components that have a specific role (e.g., a checkbox or button), use the `aria-role`, `aria-state`, and `aria-label` props on `\u003cBox\u003e` and `\u003cText\u003e` to provide semantic meaning to screen readers.\n\nFor a practical example of building an accessible component, see the [ARIA example](/examples/aria/aria.tsx).\n\n## Useful Components\n\n- [ink-text-input](https://github.com/vadimdemedes/ink-text-input) - Text input.\n- [ink-spinner](https://github.com/vadimdemedes/ink-spinner) - Spinner.\n- [ink-select-input](https://github.com/vadimdemedes/ink-select-input) - Select (dropdown) input.\n- [ink-link](https://github.com/sindresorhus/ink-link) - Link.\n- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color.\n- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text.\n- [ink-picture](https://github.com/endernoke/ink-picture) - Display images.\n- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab.\n- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings.\n- [ink-multi-select](https://github.com/karaggeorge/ink-multi-select) - Select one or more values from a list\n- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider.\n- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) - Progress bar.\n- [ink-table](https://github.com/maticzav/ink-table) - Table.\n- [ink-ascii](https://github.com/hexrcs/ink-ascii) - Awesome text component with more font choices, based on Figlet.\n- [ink-markdown](https://github.com/cameronhunter/ink-markdown) - Render syntax highlighted Markdown.\n- [ink-quicksearch-input](https://github.com/Eximchain/ink-quicksearch-input) - Select component with fast, quicksearch-like navigation.\n- [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input.\n- [ink-syntax-highlight](https://github.com/vsashyn/ink-syntax-highlight) - Code syntax highlighting.\n- [ink-form](https://github.com/lukasbach/ink-form) - Form.\n- [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list.\n- [ink-spawn](https://github.com/kraenhansen/ink-spawn) - Spawn child processes.\n- [ink-titled-box](https://github.com/mishieck/ink-titled-box) - Box with a title.\n- [ink-chart](https://github.com/pppp606/ink-chart) - Sparkline and bar chart.\n- [ink-scroll-view](https://github.com/ByteLandTechnology/ink-scroll-view) - Scroll container.\n- [ink-scroll-list](https://github.com/ByteLandTechnology/ink-scroll-list) - Scrollable list.\n- [ink-stepper](https://github.com/archcorsair/ink-stepper) - Step-by-step wizard.\n- [ink-virtual-list](https://github.com/archcorsair/ink-virtual-list) - Virtualized list that renders only visible items for performance.\n- [ink-color-picker](https://github.com/sina-byn/ink-color-picker) - Color picker.\n\n## Useful Hooks\n\n- [ink-use-stdout-dimensions](https://github.com/cameronhunter/ink-monorepo/tree/master/packages/ink-use-stdout-dimensions) - Subscribe to stdout dimensions.\n\n## Recipes\n\n- [Routing with React Router](recipes/routing.md) - Navigate between routes using `MemoryRouter`.\n\n## Examples\n\nThe [`examples`](/examples) directory contains a set of real examples. You can run them with:\n\n```bash\nnpm run example examples/[example name]\n# e.g. npm run example examples/borders\n```\n\n- [Jest](examples/jest/jest.tsx) - Implementation of basic Jest UI.\n- [Counter](examples/counter/counter.tsx) - A simple counter that increments every 100ms.\n- [Form with validation](https://github.com/final-form/rff-cli-example) - Manage form state using [Final Form](https://github.com/final-form/final-form#-final-form).\n- [Borders](examples/borders/borders.tsx) - Add borders to the `\u003cBox\u003e` component.\n- [Suspense](examples/suspense/suspense.tsx) - Use React Suspense.\n- [Table](examples/table/table.tsx) - Renders a table with multiple columns and rows.\n- [Focus management](examples/use-focus/use-focus.tsx) - Use the `useFocus` hook to manage focus between components.\n- [User input](examples/use-input/use-input.tsx) - Listen for user input.\n- [Write to stdout](examples/use-stdout/use-stdout.tsx) - Write to stdout, bypassing main Ink output.\n- [Write to stderr](examples/use-stderr/use-stderr.tsx) - Write to stderr, bypassing main Ink output.\n- [Static](examples/static/static.tsx) - Use the `\u003cStatic\u003e` component to render permanent output.\n- [Child process](examples/subprocess-output) - Renders output from a child process.\n- [Router](examples/router/router.tsx) - Navigate between routes using React Router's `MemoryRouter`.\n\n## Continuous Integration\n\nWhen running on CI (detected via the `CI` environment variable), Ink adapts its rendering:\n\n- Only the last frame is rendered on exit, instead of continuously updating the terminal. This is because most CI environments don't support the ANSI escape sequences used to overwrite previous output.\n- Terminal resize events are not listened to.\n\nIf your CI environment supports full terminal rendering and you want to opt out of this behavior, set `CI=false`:\n\n```sh\nCI=false node my-cli.js\n```\n\n## Maintainers\n\n- [Vadim Demedes](https://github.com/vadimdemedes)\n- [Sindre Sorhus](https://github.com/sindresorhus)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimdemedes%2Fink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvadimdemedes%2Fink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvadimdemedes%2Fink/lists"}