{"name":"ink","version":"5.2.1","keywords":["react","cli","jsx","stdout","components","command-line","preact","redux","print","render","colors","text"],"author":{"url":"https://github.com/vadimdemedes","name":"Vadim Demedes","email":"vadimdemedes@hey.com"},"license":"MIT","_id":"ink@5.2.1","maintainers":[{"name":"vdemedes","email":"vadimdemedes@hey.com"},{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/vadimdemedes/ink#readme","bugs":{"url":"https://github.com/vadimdemedes/ink/issues"},"xo":{"rules":{"complexity":"off","react/jsx-indent":"off","react/prop-types":"off","unicorn/import-index":"off","react/state-in-constructor":"off","react-hooks/exhaustive-deps":"off","react/no-unescaped-entities":"off","import/no-useless-path-segments":"off"},"extends":["xo-react"],"ignores":["src/parse-keypress.ts"],"plugins":["react"],"prettier":true,"overrides":[{"files":["src/**/*.{ts,tsx}","test/**/*.{ts,tsx}"],"rules":{"camelcase":["error",{"allow":["^unstable__","^internal_"]}],"dot-notation":"off","no-unused-expressions":"off","unicorn/filename-case":"off","react/boolean-prop-naming":"off","react/require-default-props":"off","unicorn/prefer-event-target":"off","unicorn/prevent-abbreviations":"off","react/jsx-curly-brace-presence":"off","unicorn/prefer-dom-node-remove":"off","@typescript-eslint/no-empty-function":"off","react/default-props-match-prop-types":"off","@typescript-eslint/promise-function-async":"warn","@typescript-eslint/explicit-function-return":"off","@typescript-eslint/explicit-function-return-type":"off"}},{"files":["examples/**/*.{ts,tsx}","benchmark/**/*.{ts,tsx}"],"rules":{"import/no-unassigned-import":"off"}}]},"ava":{"files":["test/**/*","!test/helpers/**/*","!test/fixtures/**/*"],"extensions":{"ts":"module","tsx":"module"},"nodeArguments":["--loader=ts-node/esm"],"workerThreads":false},"dist":{"shasum":"b9ea59f0d1eab2b4566903b35b54fd34323d1694","tarball":"http://registry-npm.ywwl.com/ink/download/ink-5.2.1.tgz","fileCount":137,"integrity":"sha512-BqcUyWrG9zq5HIwW6JcfFHsIYebJkWWb4fczNah1goUO0vv5vneIlfwuS85twyJ5hYR/y18FlAYUxrO9ChIWVg==","signatures":[{"sig":"MEUCIQDsFPXxNg42+p8T6cEKQ0U8Q9uxKTvFl4JB4j/ciqNZIwIgKGn9Yp0r8QsAa8W2xL29bd5sGkvLBZ9nh+XpaKbVd8Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":299800,"size":70903,"noattachment":false,"key":"/ink/-/ink-5.2.1.tgz"},"type":"module","engines":{"node":">=18"},"exports":{"types":"./build/index.d.ts","default":"./build/index.js"},"gitHead":"991aaa54eae39e1ad6d1964e747ea936d5a4ad12","scripts":{"dev":"tsc --watch","test":"tsc --noEmit && xo && FORCE_COLOR=true ava","build":"tsc","example":"NODE_NO_WARNINGS=1 node --loader ts-node/esm","prepare":"npm run build","benchmark":"NODE_NO_WARNINGS=1 node --loader ts-node/esm"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"prettier":"@vdemedes/prettier-config","repository":{"url":"git+https://github.com/vadimdemedes/ink.git","type":"git"},"_npmVersion":"10.9.2","description":"React for CLI","directories":{},"_nodeVersion":"23.6.1","dependencies":{"ws":"^8.18.0","chalk":"^5.3.0","is-in-ci":"^1.0.0","auto-bind":"^5.0.1","cli-boxes":"^3.0.0","scheduler":"^0.23.0","type-fest":"^4.27.0","wrap-ansi":"^9.0.0","cli-cursor":"^4.0.0","es-toolkit":"^1.22.0","slice-ansi":"^7.1.0","ansi-styles":"^6.2.1","signal-exit":"^3.0.7","stack-utils":"^2.0.6","widest-line":"^5.0.0","yoga-layout":"~3.2.1","ansi-escapes":"^7.0.0","cli-truncate":"^4.0.0","code-excerpt":"^4.0.0","string-width":"^7.2.0","indent-string":"^5.0.0","patch-console":"^2.0.0","react-reconciler":"^0.29.0","@alcalzone/ansi-tokenize":"^0.1.3"},"_hasShrinkwrap":false,"devDependencies":{"ms":"^2.1.3","xo":"^0.59.3","ava":"^5.1.1","boxen":"^8.0.1","delay":"^6.0.0","react":"^18.0.0","sinon":"^19.0.2","p-queue":"^8.0.0","ts-node":"^10.9.2","node-pty":"^1.0.0","prettier":"^3.3.3","@types/ms":"^0.7.31","@types/ws":"^8.5.13","strip-ansi":"^7.1.0","typescript":"^5.6.3","@types/node":"^22.9.0","@types/react":"^18.3.12","@types/sinon":"^17.0.3","@faker-js/faker":"^9.2.0","@types/benchmark":"^2.1.2","@types/scheduler":"^0.23.0","@types/signal-exit":"^3.0.0","@types/stack-utils":"^2.0.2","eslint-plugin-react":"^7.37.2","react-devtools-core":"^5.0.0","@sindresorhus/tsconfig":"^6.0.0","eslint-config-xo-react":"0.27.0","@types/react-reconciler":"^0.28.2","@vdemedes/prettier-config":"^2.0.1","eslint-plugin-react-hooks":"^5.0.0"},"peerDependencies":{"react":">=18.0.0","@types/react":">=18.0.0","react-devtools-core":"^4.19.1"},"peerDependenciesMeta":{"@types/react":{"optional":true},"react-devtools-core":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/ink_5.2.1_1745923903159_0.7854762415613428","host":"s3://npm-registry-packages-npm-production"},"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<div align=\"center\">\n\t<br>\n\t<br>\n\t<img width=\"240\" alt=\"Ink\" src=\"media/logo.png\">\n\t<br>\n\t<br>\n\t<br>\n</div>\n\n> 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**Fully AI-generated pull requests are not accepted. You can use AI, but should be verified and cleaned up by a human. Only Opus 4.6+ (high-effort) and Codex 5.4+ (extra high) are accepted models. Preferably created with Opus and verified by Codex.**\n\n---\n\n<div align=\"center\">\n\t<p>\n\t\t<p>\n\t\t\t<sup>\n\t\t\t\t<a href=\"https://opencollective.com/vadimdemedes\">My open source work is supported by the community ❤️</a>\n\t\t\t</sup>\n\t\t</p>\n\t</p>\n</div>\n\n## Install\n\n```sh\nnpm install ink react\n```\n\n> [!NOTE]\n> 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 = () => {\n\tconst [counter, setCounter] = useState(0);\n\n\tuseEffect(() => {\n\t\tconst timer = setInterval(() => {\n\t\t\tsetCounter(previousCounter => previousCounter + 1);\n\t\t}, 100);\n\n\t\treturn () => {\n\t\t\tclearInterval(timer);\n\t\t};\n\t}, []);\n\n\treturn <Text color=\"green\">{counter} tests passed</Text>;\n};\n\nrender(<Counter />);\n```\n\n<img src=\"media/demo.svg\" width=\"600\">\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- [Deep Code CLI](https://github.com/lessweb/deepcode-cli) - AI coding assistant optimized for the DeepSeek model.\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  - [`<Text>`](#text)\n  - [`<Box>`](#box)\n  - [`<Newline>`](#newline)\n  - [`<Spacer>`](#spacer)\n  - [`<Static>`](#static)\n  - [`<Transform>`](#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  - [`useAnimation`](#useanimationoptions)\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<details><summary>Manual JavaScript setup</summary>\n<p>\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 = () => <Text>Hello World</Text>;\n\nrender(<Demo />);\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</p>\n</details>\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 `<div>` in the browser had `display: flex`.\nSee [`<Box>`](#box) built-in component below for documentation on how to use Flexbox layouts in Ink.\nNote that all text must be wrapped in a [`<Text>`](#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(<MyApp />);\n\nawait waitUntilExit();\n\nconsole.log('App exited');\n```\n\n## Components\n\n### `<Text>`\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 = () => (\n\t<>\n\t\t<Text color=\"green\">I am green</Text>\n\t\t<Text color=\"black\" backgroundColor=\"white\">\n\t\t\tI am black on white\n\t\t</Text>\n\t\t<Text color=\"#ffffff\">I am white</Text>\n\t\t<Text bold>I am bold</Text>\n\t\t<Text italic>I am italic</Text>\n\t\t<Text underline>I am underline</Text>\n\t\t<Text strikethrough>I am strikethrough</Text>\n\t\t<Text inverse>I am inversed</Text>\n\t</>\n);\n\nrender(<Example />);\n```\n\n> [!NOTE]\n> `<Text>` allows only text nodes and nested `<Text>` components inside of it. For example, `<Box>` component can't be used inside `<Text>`.\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<Text color=\"green\">Green</Text>\n<Text color=\"#005cc5\">Blue</Text>\n<Text color=\"rgb(232, 131, 136)\">Red</Text>\n```\n\n<img src=\"media/text-color.jpg\" width=\"247\">\n\n#### backgroundColor\n\nType: `string`\n\nSame as `color` above, but for background.\n\n```jsx\n<Text backgroundColor=\"green\" color=\"white\">Green</Text>\n<Text backgroundColor=\"#005cc5\" color=\"white\">Blue</Text>\n<Text backgroundColor=\"rgb(232, 131, 136)\" color=\"white\">Red</Text>\n```\n\n<img src=\"media/text-backgroundColor.jpg\" width=\"226\">\n\n#### dimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the color (make it less bright).\n\n```jsx\n<Text color=\"red\" dimColor>\n\tDimmed Red\n</Text>\n```\n\n<img src=\"media/text-dimColor.jpg\" width=\"138\">\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<Text inverse color=\"yellow\">\n\tInversed Yellow\n</Text>\n```\n\n<img src=\"media/text-inverse.jpg\" width=\"138\">\n\n#### wrap\n\nType: `string`\\\nAllowed values: `wrap` `hard` `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 `hard` is passed, Ink will fill each line to the full column width, breaking words as necessary.\nIf `truncate-*` is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off.\n\n```jsx\n<Box width={7}>\n\t<Text>Hello World</Text>\n</Box>\n//=> 'Hello\\nWorld'\n\n<Box width={7}>\n\t<Text wrap=\"hard\">Hello World</Text>\n</Box>\n//=> 'Hello W\\norld'\n\n// `truncate` is an alias to `truncate-end`\n<Box width={7}>\n\t<Text wrap=\"truncate\">Hello World</Text>\n</Box>\n//=> 'Hello…'\n\n<Box width={7}>\n\t<Text wrap=\"truncate-middle\">Hello World</Text>\n</Box>\n//=> 'He…ld'\n\n<Box width={7}>\n\t<Text wrap=\"truncate-start\">Hello World</Text>\n</Box>\n//=> '…World'\n```\n\n### `<Box>`\n\n`<Box>` is an essential Ink component to build your layout.\nIt's like `<div style=\"display: flex\">` in the browser.\n\n```jsx\nimport {render, Box, Text} from 'ink';\n\nconst Example = () => (\n\t<Box margin={2}>\n\t\t<Text>This is a box with margin</Text>\n\t</Box>\n);\n\nrender(<Example />);\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<Box width={4}>\n\t<Text>X</Text>\n</Box>\n//=> 'X   '\n```\n\n```jsx\n<Box width={10}>\n\t<Box width=\"50%\">\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>Y</Text>\n</Box>\n//=> '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<Box height={4}>\n\t<Text>X</Text>\n</Box>\n//=> 'X\\n\\n\\n'\n```\n\n```jsx\n<Box height={6} flexDirection=\"column\">\n\t<Box height=\"50%\">\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>Y</Text>\n</Box>\n//=> '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<Box paddingTop={2}><Text>Top</Text></Box>\n<Box paddingBottom={2}><Text>Bottom</Text></Box>\n<Box paddingLeft={2}><Text>Left</Text></Box>\n<Box paddingRight={2}><Text>Right</Text></Box>\n<Box paddingX={2}><Text>Left and right</Text></Box>\n<Box paddingY={2}><Text>Top and bottom</Text></Box>\n<Box padding={2}><Text>Top, bottom, left and right</Text></Box>\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<Box marginTop={2}><Text>Top</Text></Box>\n<Box marginBottom={2}><Text>Bottom</Text></Box>\n<Box marginLeft={2}><Text>Left</Text></Box>\n<Box marginRight={2}><Text>Right</Text></Box>\n<Box marginX={2}><Text>Left and right</Text></Box>\n<Box marginY={2}><Text>Top and bottom</Text></Box>\n<Box margin={2}><Text>Top, bottom, left and right</Text></Box>\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<Box gap={1} width={3} flexWrap=\"wrap\">\n\t<Text>A</Text>\n\t<Text>B</Text>\n\t<Text>C</Text>\n</Box>\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<Box columnGap={1}>\n\t<Text>A</Text>\n\t<Text>B</Text>\n</Box>\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<Box flexDirection=\"column\" rowGap={1}>\n\t<Text>A</Text>\n\t<Text>B</Text>\n</Box>\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<Box>\n\t<Text>Label:</Text>\n\t<Box flexGrow={1}>\n\t\t<Text>Fills all remaining space</Text>\n\t</Box>\n</Box>\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<Box width={20}>\n\t<Box flexShrink={2} width={10}>\n\t\t<Text>Will be 1/4</Text>\n\t</Box>\n\t<Box width={10}>\n\t\t<Text>Will be 3/4</Text>\n\t</Box>\n</Box>\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<Box width={6}>\n\t<Box flexBasis={3}>\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>Y</Text>\n</Box>\n//=> 'X  Y'\n```\n\n```jsx\n<Box width={6}>\n\t<Box flexBasis=\"50%\">\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>Y</Text>\n</Box>\n//=> '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<Box>\n\t<Box marginRight={1}>\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>Y</Text>\n</Box>\n// X Y\n\n<Box flexDirection=\"row-reverse\">\n\t<Text>X</Text>\n\t<Box marginRight={1}>\n\t\t<Text>Y</Text>\n\t</Box>\n</Box>\n// Y X\n\n<Box flexDirection=\"column\">\n\t<Text>X</Text>\n\t<Text>Y</Text>\n</Box>\n// X\n// Y\n\n<Box flexDirection=\"column-reverse\">\n\t<Text>X</Text>\n\t<Text>Y</Text>\n</Box>\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<Box width={2} flexWrap=\"wrap\">\n\t<Text>A</Text>\n\t<Text>BC</Text>\n</Box>\n// A\n// B C\n```\n\n```jsx\n<Box flexDirection=\"column\" height={2} flexWrap=\"wrap\">\n\t<Text>A</Text>\n\t<Text>B</Text>\n\t<Text>C</Text>\n</Box>\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<Box alignItems=\"flex-start\">\n\t<Box marginRight={1}>\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>\n\t\tA\n\t\t<Newline/>\n\t\tB\n\t\t<Newline/>\n\t\tC\n\t</Text>\n</Box>\n// X A\n//   B\n//   C\n\n<Box alignItems=\"center\">\n\t<Box marginRight={1}>\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>\n\t\tA\n\t\t<Newline/>\n\t\tB\n\t\t<Newline/>\n\t\tC\n\t</Text>\n</Box>\n//   A\n// X B\n//   C\n\n<Box alignItems=\"flex-end\">\n\t<Box marginRight={1}>\n\t\t<Text>X</Text>\n\t</Box>\n\t<Text>\n\t\tA\n\t\t<Newline/>\n\t\tB\n\t\t<Newline/>\n\t\tC\n\t</Text>\n</Box>\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<Box height={3}>\n\t<Box alignSelf=\"flex-start\">\n\t\t<Text>X</Text>\n\t</Box>\n</Box>\n// X\n//\n//\n\n<Box height={3}>\n\t<Box alignSelf=\"center\">\n\t\t<Text>X</Text>\n\t</Box>\n</Box>\n//\n// X\n//\n\n<Box height={3}>\n\t<Box alignSelf=\"flex-end\">\n\t\t<Text>X</Text>\n\t</Box>\n</Box>\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<Box justifyContent=\"flex-start\">\n\t<Text>X</Text>\n</Box>\n// [X      ]\n\n<Box justifyContent=\"center\">\n\t<Text>X</Text>\n</Box>\n// [   X   ]\n\n<Box justifyContent=\"flex-end\">\n\t<Text>X</Text>\n</Box>\n// [      X]\n\n<Box justifyContent=\"space-between\">\n\t<Text>X</Text>\n\t<Text>Y</Text>\n</Box>\n// [X      Y]\n\n<Box justifyContent=\"space-around\">\n\t<Text>X</Text>\n\t<Text>Y</Text>\n</Box>\n// [  X   Y  ]\n\n<Box justifyContent=\"space-evenly\">\n\t<Text>X</Text>\n\t<Text>Y</Text>\n</Box>\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<Box flexDirection=\"column\">\n\t<Box>\n\t\t<Box borderStyle=\"single\" marginRight={2}>\n\t\t\t<Text>single</Text>\n\t\t</Box>\n\n\t\t<Box borderStyle=\"double\" marginRight={2}>\n\t\t\t<Text>double</Text>\n\t\t</Box>\n\n\t\t<Box borderStyle=\"round\" marginRight={2}>\n\t\t\t<Text>round</Text>\n\t\t</Box>\n\n\t\t<Box borderStyle=\"bold\">\n\t\t\t<Text>bold</Text>\n\t\t</Box>\n\t</Box>\n\n\t<Box marginTop={1}>\n\t\t<Box borderStyle=\"singleDouble\" marginRight={2}>\n\t\t\t<Text>singleDouble</Text>\n\t\t</Box>\n\n\t\t<Box borderStyle=\"doubleSingle\" marginRight={2}>\n\t\t\t<Text>doubleSingle</Text>\n\t\t</Box>\n\n\t\t<Box borderStyle=\"classic\">\n\t\t\t<Text>classic</Text>\n\t\t</Box>\n\t</Box>\n</Box>\n```\n\n<img src=\"media/box-borderStyle.jpg\" width=\"521\">\n\nAlternatively, pass a custom border style like so:\n\n```jsx\n<Box\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>\n\t<Text>Custom</Text>\n</Box>\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<Box borderStyle=\"round\" borderColor=\"green\">\n\t<Text>Green Rounded Box</Text>\n</Box>\n```\n\n<img src=\"media/box-borderColor.jpg\" width=\"228\">\n\n##### borderTopColor\n\nType: `string`\n\nChange top border color.\nAccepts the same values as [`color`](#color) in `<Text>` component.\n\n```jsx\n<Box borderStyle=\"round\" borderTopColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderRightColor\n\nType: `string`\n\nChange the right border color.\nAccepts the same values as [`color`](#color) in `<Text>` component.\n\n```jsx\n<Box borderStyle=\"round\" borderRightColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderBottomColor\n\nType: `string`\n\nChange the bottom border color.\nAccepts the same values as [`color`](#color) in `<Text>` component.\n\n```jsx\n<Box borderStyle=\"round\" borderBottomColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderLeftColor\n\nType: `string`\n\nChange the left border color.\nAccepts the same values as [`color`](#color) in `<Text>` component.\n\n```jsx\n<Box borderStyle=\"round\" borderLeftColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\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<Box borderStyle=\"round\" borderDimColor>\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderTopDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the top border color.\n\n```jsx\n<Box borderStyle=\"round\" borderTopDimColor>\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderBottomDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the bottom border color.\n\n```jsx\n<Box borderStyle=\"round\" borderBottomDimColor>\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderLeftDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the left border color.\n\n```jsx\n<Box borderStyle=\"round\" borderLeftDimColor>\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderRightDimColor\n\nType: `boolean`\\\nDefault: `false`\n\nDim the right border color.\n\n```jsx\n<Box borderStyle=\"round\" borderRightDimColor>\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderBackgroundColor\n\nType: `string`\n\nChange border background color.\nAccepts the same values as [`backgroundColor`](#backgroundcolor) in `<Text>` component.\nA shorthand for setting `borderTopBackgroundColor`, `borderRightBackgroundColor`, `borderBottomBackgroundColor`, and `borderLeftBackgroundColor`.\n\n```jsx\n<Box borderStyle=\"round\" borderColor=\"white\" borderBackgroundColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderTopBackgroundColor\n\nType: `string`\n\nChange top border background color.\nAccepts the same values as [`backgroundColor`](#backgroundcolor) in `<Text>` component.\nFalls back to `borderBackgroundColor` if not specified.\n\n```jsx\n<Box borderStyle=\"round\" borderColor=\"white\" borderTopBackgroundColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderBottomBackgroundColor\n\nType: `string`\n\nChange bottom border background color.\nAccepts the same values as [`backgroundColor`](#backgroundcolor) in `<Text>` component.\nFalls back to `borderBackgroundColor` if not specified.\n\n```jsx\n<Box\n\tborderStyle=\"round\"\n\tborderColor=\"white\"\n\tborderBottomBackgroundColor=\"green\"\n>\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderRightBackgroundColor\n\nType: `string`\n\nChange right border background color.\nAccepts the same values as [`backgroundColor`](#backgroundcolor) in `<Text>` component.\nFalls back to `borderBackgroundColor` if not specified.\n\n```jsx\n<Box borderStyle=\"round\" borderColor=\"white\" borderRightBackgroundColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\n```\n\n##### borderLeftBackgroundColor\n\nType: `string`\n\nChange left border background color.\nAccepts the same values as [`backgroundColor`](#backgroundcolor) in `<Text>` component.\nFalls back to `borderBackgroundColor` if not specified.\n\n```jsx\n<Box borderStyle=\"round\" borderColor=\"white\" borderLeftBackgroundColor=\"green\">\n\t<Text>Hello world</Text>\n</Box>\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 `<Text>` component.\n\n```jsx\n<Box flexDirection=\"column\">\n\t<Box backgroundColor=\"red\" width={20} height={5} alignSelf=\"flex-start\">\n\t\t<Text>Red background</Text>\n\t</Box>\n\n\t<Box\n\t\tbackgroundColor=\"#FF8800\"\n\t\twidth={20}\n\t\theight={3}\n\t\tmarginTop={1}\n\t\talignSelf=\"flex-start\"\n\t>\n\t\t<Text>Orange background</Text>\n\t</Box>\n\n\t<Box\n\t\tbackgroundColor=\"rgb(0, 255, 0)\"\n\t\twidth={20}\n\t\theight={3}\n\t\tmarginTop={1}\n\t\talignSelf=\"flex-start\"\n\t>\n\t\t<Text>Green background</Text>\n\t</Box>\n</Box>\n```\n\nThe background color fills the entire `<Box>` area and is inherited by child `<Text>` components unless they specify their own `backgroundColor`.\n\n```jsx\n<Box backgroundColor=\"blue\" alignSelf=\"flex-start\">\n\t<Text>Blue inherited </Text>\n\t<Text backgroundColor=\"yellow\">Yellow override </Text>\n\t<Text>Blue inherited again</Text>\n</Box>\n```\n\nBackground colors work with borders and padding:\n\n```jsx\n<Box\n\tbackgroundColor=\"cyan\"\n\tborderStyle=\"round\"\n\tpadding={1}\n\talignSelf=\"flex-start\"\n>\n\t<Text>Background with border and padding</Text>\n</Box>\n```\n\nSee example in [examples/box-backgrounds](examples/box-backgrounds/box-backgrounds.tsx).\n\n### `<Newline>`\n\nAdds one or more newline (`\\n`) characters.\nMust be used within `<Text>` 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 = () => (\n\t<Text>\n\t\t<Text color=\"green\">Hello</Text>\n\t\t<Newline />\n\t\t<Text color=\"red\">World</Text>\n\t</Text>\n);\n\nrender(<Example />);\n```\n\nOutput:\n\n```\nHello\nWorld\n```\n\n### `<Spacer>`\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 `<Spacer>` in a `<Box>` 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 = () => (\n\t<Box>\n\t\t<Text>Left</Text>\n\t\t<Spacer />\n\t\t<Text>Right</Text>\n\t</Box>\n);\n\nrender(<Example />);\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 = () => (\n\t<Box flexDirection=\"column\" height={10}>\n\t\t<Text>Top</Text>\n\t\t<Spacer />\n\t\t<Text>Bottom</Text>\n\t</Box>\n);\n\nrender(<Example />);\n```\n\n### `<Static>`\n\n`<Static>` 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 `<Static>` 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 `<Static>` 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 = () => {\n\tconst [tests, setTests] = useState([]);\n\n\tuseEffect(() => {\n\t\tlet completedTests = 0;\n\t\tlet timer;\n\n\t\tconst run = () => {\n\t\t\t// Fake 10 completed tests\n\t\t\tif (completedTests++ < 10) {\n\t\t\t\tsetTests(previousTests => [\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 () => {\n\t\t\tclearTimeout(timer);\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t<>\n\t\t\t{/* This part will be rendered once to the terminal */}\n\t\t\t<Static items={tests}>\n\t\t\t\t{test => (\n\t\t\t\t\t<Box key={test.id}>\n\t\t\t\t\t\t<Text color=\"green\">✔ {test.title}</Text>\n\t\t\t\t\t</Box>\n\t\t\t\t)}\n\t\t\t</Static>\n\n\t\t\t{/* This part keeps updating as state changes */}\n\t\t\t<Box marginTop={1}>\n\t\t\t\t<Text dimColor>Completed tests: {tests.length}</Text>\n\t\t\t</Box>\n\t\t</>\n\t);\n};\n\nrender(<Example />);\n```\n\n> [!NOTE]\n> `<Static>` only renders new items in the `items` prop and ignores items that were previously rendered. This means that when you add new items to the `items` array, changes you make to previous items will not trigger a rerender.\n\nSee [examples/static](examples/static/static.tsx) for an example usage of `<Static>` 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 [`<Box>`](#box) for supported properties.\n\n```jsx\n<Static items={...} style={{padding: 1}}>\n\t{...}\n</Static>\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<Static items={['a', 'b', 'c']}>\n\t{(item, index) => {\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<Box key={index}>\n\t\t\t\t<Text>Item: {item}</Text>\n\t\t\t</Box>\n\t\t);\n\t}}\n</Static>\n```\n\n### `<Transform>`\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 `<Transform>` component does: it gives you an output string of its child components and lets you transform it in any way.\n\n> [!NOTE]\n> `<Transform>` must be applied only to `<Text>` children components and shouldn't change the dimensions of the output; otherwise, the layout will be incorrect.\n\n> [!IMPORTANT]\n> When children use `<Text>` 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 = () => (\n\t<Transform transform={output => output.toUpperCase()}>\n\t\t<Text>Hello World</Text>\n\t</Transform>\n);\n\nrender(<Example />);\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}) => (\n\t<Transform\n\t\ttransform={(line, index) =>\n\t\t\tindex === 0 ? line : ' '.repeat(indent) + line\n\t\t}\n\t>\n\t\t{children}\n\t</Transform>\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(<HangingIndent indent={4}>{text}</HangingIndent>);\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 = () => {\n\tuseInput((input, key) => {\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 = () => {\n\tuseInput((input, key) => {\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) => {\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\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 = () => {\n\tconst {exit} = useApp();\n\n\t// Exit the app after 5 seconds\n\tuseEffect(() => {\n\t\tsetTimeout(() => {\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 = () => {\n\tconst {waitUntilRenderFlush} = useApp();\n\n\tuseEffect(() => {\n\t\tvoid (async () => {\n\t\t\tawait waitUntilRenderFlush();\n\t\t\trunNextCommand();\n\t\t})();\n\t}, [waitUntilRenderFlush]);\n\n\treturn …;\n};\n```\n\n#### suspendTerminal(callback?)\n\nType: `Function`\n\nTemporarily hands the terminal over to a child process (such as `$EDITOR`, `less`, or `fzf`), then restores Ink's terminal state and forces a full redraw.\n\nWhile suspended, Ink stops writing output, stops consuming input, and restores the terminal modes the child expects (raw mode off, cursor visible, bracketed paste off, alternate screen exited, kitty keyboard protocol off). When the suspension ends, Ink reapplies its own terminal state and repaints from scratch.\n\n##### callback\n\nType: `Function`\n\nWhen a callback is provided, Ink suspends, runs the callback, and restores the terminal once it settles, even if the callback throws.\n\n```js\nimport {useApp} from 'ink';\n\nconst {suspendTerminal} = useApp();\n\nawait suspendTerminal(async () => {\n\tawait runEditor();\n});\n```\n\nWhen called without a callback, it returns a suspension you resume yourself. `resume()` is async because restoring the terminal may need to wait for ordered writes and a full redraw.\n\n```js\nconst suspension = await suspendTerminal();\n\ntry {\n\tawait runEditor();\n} finally {\n\tawait suspension.resume();\n}\n```\n\nThe suspension is also a disposable, so it can be resumed automatically with `await using`:\n\n```js\nawait using suspension = await suspendTerminal();\nawait runEditor();\n```\n\nSuspending while a suspension is already active throws. This is supported only in interactive TTY mode; in non-interactive output the callback still runs but Ink performs no terminal handoff.\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 = () => {\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 = () => {\n\tconst {isRawModeSupported} = useStdin();\n\n\treturn isRawModeSupported ? (\n\t\t<MyInputComponent />\n\t) : (\n\t\t<MyComponentThatDoesntUseInput />\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 <kbd>Ctrl</kbd>+<kbd>C</kbd>, 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 = () => {\n\tconst {setRawMode} = useStdin();\n\n\tuseEffect(() => {\n\t\tsetRawMode(true);\n\n\t\treturn () => {\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 = () => {\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 `<Static>`, 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 = () => {\n\tconst {write} = useStdout();\n\n\tuseEffect(() => {\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<DOMElement | null>`\n\nA ref to the `<Box>` element to track.\n\n```jsx\nimport {useRef} from 'react';\nimport {Box, Text, useBoxMetrics} from 'ink';\n\nconst Example = () => {\n\tconst ref = useRef(null);\n\tconst {width, height, left, top, hasMeasured} = useBoxMetrics(ref);\n\n\treturn (\n\t\t<Box ref={ref}>\n\t\t\t<Text>\n\t\t\t\t{hasMeasured ? `${width}x${height} at ${left},${top}` : 'Measuring...'}\n\t\t\t</Text>\n\t\t</Box>\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> [!NOTE]\n> 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 = () => {\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 `<Static>`, 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 = () => {\n\tconst {write} = useStderr();\n\n\tuseEffect(() => {\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 = () => {\n\tconst {columns, rows} = useWindowSize();\n\n\treturn (\n\t\t<Text>\n\t\t\t{columns}x{rows}\n\t\t</Text>\n\t);\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> [!NOTE]\n> When the terminal is resized narrower, ghost lines may briefly appear depending on the terminal emulator's reflow behavior.\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 <kbd>Tab</kbd>, 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 = () => {\n\tconst {isFocused} = useFocus();\n\n\treturn <Text>{isFocused ? 'I am focused' : 'I am not focused'}</Text>;\n};\n\nrender(<Example />);\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> [!NOTE]\n> 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 = () => {\n\tconst {enableFocus} = useFocusManager();\n\n\tuseEffect(() => {\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 = () => {\n\tconst {disableFocus} = useFocusManager();\n\n\tuseEffect(() => {\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> [!NOTE]\n> Ink calls this method when user presses <kbd>Tab</kbd>.\n\n```js\nimport {useFocusManager} from 'ink';\n\nconst Example = () => {\n\tconst {focusNext} = useFocusManager();\n\n\tuseEffect(() => {\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> [!NOTE]\n> Ink calls this method when user presses <kbd>Shift</kbd>+<kbd>Tab</kbd>.\n\n```js\nimport {useFocusManager} from 'ink';\n\nconst Example = () => {\n\tconst {focusPrevious} = useFocusManager();\n\n\tuseEffect(() => {\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 = () => {\n\tconst {focus} = useFocusManager();\n\n\tuseInput(input => {\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 = () => {\n\tconst {activeId} = useFocusManager();\n\n\treturn <Text>Focused: {activeId ?? 'none'}</Text>;\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 = () => {\n\tconst [text, setText] = useState('');\n\tconst {setCursorPosition} = useCursor();\n\n\tconst prompt = '> ';\n\tsetCursorPosition({x: stringWidth(prompt + text), y: 1});\n\n\treturn (\n\t\t<Box flexDirection=\"column\">\n\t\t\t<Text>Type here:</Text>\n\t\t\t<Text>\n\t\t\t\t{prompt}\n\t\t\t\t{text}\n\t\t\t</Text>\n\t\t</Box>\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 = () => {\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\treturn (\n\t\t<Text>\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</Text>\n\t);\n};\n```\n\n### useAnimation(options?)\n\nA React hook that drives animations. Returns a frame counter, elapsed time, frame delta, and a reset function. All animations share a single timer internally, so multiple animated components consolidate into one render cycle.\n\n```jsx\nimport {Text, useAnimation} from 'ink';\n\nconst Spinner = () => {\n\tconst {frame} = useAnimation({interval: 80});\n\tconst characters = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n\treturn <Text>{characters[frame % characters.length]}</Text>;\n};\n```\n\n#### options\n\nType: `object`\n\n##### interval\n\nType: `number`\\\nDefault: `100`\n\nTime between ticks in milliseconds.\n\n##### isActive\n\nType: `boolean`\\\nDefault: `true`\n\nWhether the animation is running. When set to `false`, the animation stops. When toggled back to `true`, all values reset to `0`.\n\n#### Return value\n\n##### frame\n\nType: `number`\n\nDiscrete counter that increments by 1 each interval. Useful for indexed sequences like spinner frames.\n\n##### time\n\nType: `number`\n\nTotal elapsed time in milliseconds since the animation started or was last reset. Useful for continuous math-based animations like sine waves: `Math.sin(time / 1000 * Math.PI * 2)`.\n\n##### delta\n\nType: `number`\n\nTime in milliseconds since the previous rendered tick. Accounts for throttled renders. Useful for physics-based or velocity-driven motion: `position += speed * delta`.\n\n##### reset\n\nType: `() => void`\n\nResets `frame`, `time`, and `delta` to `0` and restarts timing from the current moment. Useful for one-shot animations triggered by events.\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\nOnce unmount starts, Ink restores the native console before React cleanup runs. Teardown-time `console.*` output then follows the normal console behavior instead of being rerouted through Ink.\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}) => 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\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(<MyApp />, {concurrent: true});\n```\n\n> [!NOTE]\n> Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.\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> [!NOTE]\n> Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.\n\n```jsx\n// Use your own detection logic\nconst isInteractive = myCustomDetection();\nrender(<MyApp />, {interactive: isInteractive});\n```\n\n###### alternateScreen\n\nType: `boolean`\\\nDefault: `false`\n\nRender the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.\n\nNote: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.\n\nInk intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.\n\nOnly works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).\n\n> [!NOTE]\n> Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.\n\n```jsx\nrender(<MyApp />, {alternateScreen: true});\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(<MyApp />, {kittyKeyboard: {mode: 'auto'}});\n```\n\n```jsx\nimport {render} from 'ink';\n\nrender(<MyApp />, {\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`). T","publish_time":1745923903345,"_cnpm_publish_time":1745923903345,"dist-tags":{"latest":"8.0.0","next":"3.0.0-7"}}