ink 6.2.3 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/AppContext.d.ts +4 -4
- package/build/components/AppContext.js +2 -2
- package/build/components/AppContext.js.map +1 -1
- package/build/components/Box.d.ts +18 -18
- package/build/components/Box.js +2 -2
- package/build/components/Box.js.map +1 -1
- package/build/components/Newline.d.ts +6 -6
- package/build/components/Newline.js +2 -2
- package/build/components/Newline.js.map +1 -1
- package/build/components/Spacer.d.ts +4 -3
- package/build/components/Spacer.js +4 -3
- package/build/components/Spacer.js.map +1 -1
- package/build/components/Static.d.ts +12 -19
- package/build/components/Static.js +6 -11
- package/build/components/Static.js.map +1 -1
- package/build/components/StderrContext.d.ts +6 -8
- package/build/components/StderrContext.js +2 -2
- package/build/components/StderrContext.js.map +1 -1
- package/build/components/StdinContext.d.ts +8 -9
- package/build/components/StdinContext.js +2 -2
- package/build/components/StdinContext.js.map +1 -1
- package/build/components/StdoutContext.d.ts +6 -8
- package/build/components/StdoutContext.js +2 -2
- package/build/components/StdoutContext.js.map +1 -1
- package/build/components/Text.d.ts +24 -26
- package/build/components/Text.js +2 -2
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.d.ts +6 -10
- package/build/components/Transform.js +2 -5
- package/build/components/Transform.js.map +1 -1
- package/build/hooks/use-app.d.ts +2 -2
- package/build/hooks/use-app.js +2 -2
- package/build/hooks/use-app.js.map +1 -1
- package/build/hooks/use-focus-manager.d.ts +12 -18
- package/build/hooks/use-focus-manager.js +2 -3
- package/build/hooks/use-focus-manager.js.map +1 -1
- package/build/hooks/use-focus.d.ts +12 -17
- package/build/hooks/use-focus.js +2 -7
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.d.ts +54 -58
- package/build/hooks/use-input.js +20 -23
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/use-is-screen-reader-enabled.d.ts +2 -3
- package/build/hooks/use-is-screen-reader-enabled.js +2 -3
- package/build/hooks/use-is-screen-reader-enabled.js.map +1 -1
- package/build/hooks/use-stderr.d.ts +2 -2
- package/build/hooks/use-stderr.js +2 -2
- package/build/hooks/use-stderr.js.map +1 -1
- package/build/hooks/use-stdin.d.ts +2 -2
- package/build/hooks/use-stdin.js +2 -2
- package/build/hooks/use-stdin.js.map +1 -1
- package/build/hooks/use-stdout.d.ts +2 -2
- package/build/hooks/use-stdout.js +2 -2
- package/build/hooks/use-stdout.js.map +1 -1
- package/build/ink.d.ts +1 -0
- package/build/ink.js +3 -1
- package/build/ink.js.map +1 -1
- package/build/measure-element.d.ts +6 -6
- package/build/measure-element.js +2 -2
- package/build/measure-element.js.map +1 -1
- package/build/options.d.ts +52 -0
- package/build/options.js +2 -0
- package/build/options.js.map +1 -0
- package/build/output.d.ts +6 -7
- package/build/output.js.map +1 -1
- package/build/render.d.ts +45 -38
- package/build/render.js +3 -2
- package/build/render.js.map +1 -1
- package/build/styles.d.ts +132 -141
- package/build/styles.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +153 -153
package/readme.md
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
[](https://npmjs.com/package/ink)
|
|
18
18
|
|
|
19
19
|
Ink provides the same component-based UI building experience that React offers in the browser, but for command-line apps.
|
|
20
|
-
It uses [Yoga](https://github.com/facebook/yoga) to build Flexbox layouts in the terminal, so most CSS-like
|
|
20
|
+
It 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.
|
|
21
21
|
If you are already familiar with React, you already know Ink.
|
|
22
22
|
|
|
23
|
-
Since Ink is a React renderer,
|
|
24
|
-
Head over to [React](https://reactjs.org) website for documentation on how to use it.
|
|
25
|
-
Only Ink's methods
|
|
23
|
+
Since Ink is a React renderer, all features of React are supported.
|
|
24
|
+
Head over to the [React](https://reactjs.org) website for documentation on how to use it.
|
|
25
|
+
Only Ink's methods are documented in this readme.
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -69,61 +69,63 @@ render(<Counter />);
|
|
|
69
69
|
|
|
70
70
|
<img src="media/demo.svg" width="600">
|
|
71
71
|
|
|
72
|
-
Feel free to play around with the code and fork this
|
|
72
|
+
Feel free to play around with the code and fork this Repl at [https://repl.it/@vadimdemedes/ink-counter-demo](https://repl.it/@vadimdemedes/ink-counter-demo).
|
|
73
73
|
|
|
74
74
|
## Who's Using Ink?
|
|
75
75
|
|
|
76
|
-
- [Codex](https://github.com/openai/codex) - An agentic coding tool
|
|
77
|
-
- [Claude Code](https://github.com/anthropics/claude-code) - An agentic coding tool
|
|
78
|
-
- [Gemini CLI](https://github.com/google-gemini/gemini-cli) - An agentic coding tool
|
|
76
|
+
- [Codex](https://github.com/openai/codex) - An agentic coding tool made by OpenAI.
|
|
77
|
+
- [Claude Code](https://github.com/anthropics/claude-code) - An agentic coding tool made by Anthropic.
|
|
78
|
+
- [Gemini CLI](https://github.com/google-gemini/gemini-cli) - An agentic coding tool made by Google.
|
|
79
79
|
- [GitHub Copilot for CLI](https://githubnext.com/projects/copilot-cli) - Just say what you want the shell to do.
|
|
80
80
|
- [Canva CLI](https://www.canva.dev/docs/apps/canva-cli/) - CLI for creating and managing Canva Apps.
|
|
81
81
|
- [Cloudflare's Wrangler](https://github.com/cloudflare/wrangler2) - The CLI for Cloudflare Workers.
|
|
82
|
-
- [Linear](https://linear.app) - Linear built an internal CLI for managing deployments, configs and other housekeeping tasks.
|
|
83
|
-
- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing
|
|
82
|
+
- [Linear](https://linear.app) - Linear built an internal CLI for managing deployments, configs, and other housekeeping tasks.
|
|
83
|
+
- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing-fast websites.
|
|
84
84
|
- [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript.
|
|
85
|
-
- [Terraform CDK](https://github.com/hashicorp/terraform-cdk) -
|
|
85
|
+
- [Terraform CDK](https://github.com/hashicorp/terraform-cdk) - Cloud Development Kit (CDK) for HashiCorp Terraform.
|
|
86
86
|
- [Specify CLI](https://specifyapp.com) - Automate the distribution of your design tokens.
|
|
87
87
|
- [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).
|
|
88
88
|
- [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema.
|
|
89
89
|
- [Prisma](https://www.prisma.io) - The unified data layer for modern applications.
|
|
90
90
|
- [Blitz](https://blitzjs.com) - The Fullstack React Framework.
|
|
91
|
-
- [New York Times](https://github.com/nytimes/kyt) - NYT uses Ink `kyt` - a toolkit that encapsulates and manages the configuration for web apps.
|
|
92
|
-
- [tink](https://github.com/npm/tink) -
|
|
93
|
-
- [Inkle](https://github.com/jrr/inkle) - Wordle game.
|
|
94
|
-
- [loki](https://github.com/oblador/loki) - Visual regression testing for Storybook.
|
|
95
|
-
- [Bit](https://github.com/teambit/bit) - Build, distribute and collaborate on components.
|
|
91
|
+
- [New York Times](https://github.com/nytimes/kyt) - NYT uses Ink's `kyt` - a toolkit that encapsulates and manages the configuration for web apps.
|
|
92
|
+
- [tink](https://github.com/npm/tink) - A next-generation runtime and package manager.
|
|
93
|
+
- [Inkle](https://github.com/jrr/inkle) - A Wordle game.
|
|
94
|
+
- [loki](https://github.com/oblador/loki) - Visual regression testing tool for Storybook.
|
|
95
|
+
- [Bit](https://github.com/teambit/bit) - Build, distribute, and collaborate on components.
|
|
96
96
|
- [Remirror](https://github.com/remirror/remirror) - Your friendly, world-class editor toolkit.
|
|
97
|
-
- [Prime](https://github.com/birkir/prime) - Open
|
|
97
|
+
- [Prime](https://github.com/birkir/prime) - Open-source GraphQL CMS.
|
|
98
98
|
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emojis.
|
|
99
|
-
- [emma](https://github.com/maticzav/emma-cli) - Find and install npm packages.
|
|
100
|
-
- [npm-check-extras](https://github.com/akgondber/npm-check-extras) - Check for outdated and unused dependencies, and run update/delete
|
|
101
|
-
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command
|
|
102
|
-
- [share](https://github.com/marionebl/share-cli) -
|
|
103
|
-
- [Kubelive](https://github.com/ameerthehacker/kubelive) - CLI for Kubernetes
|
|
99
|
+
- [emma](https://github.com/maticzav/emma-cli) - Find and install npm packages easily.
|
|
100
|
+
- [npm-check-extras](https://github.com/akgondber/npm-check-extras) - Check for outdated and unused dependencies, and run update/delete actions on selected ones.
|
|
101
|
+
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command-line tools for time-saving web developers.
|
|
102
|
+
- [share](https://github.com/marionebl/share-cli) - Share files quickly.
|
|
103
|
+
- [Kubelive](https://github.com/ameerthehacker/kubelive) - A CLI for Kubernetes that provides live data about the cluster and its resources.
|
|
104
104
|
- [changelog-view](https://github.com/jdeniau/changelog-view) - View changelogs.
|
|
105
|
-
- [cfpush](https://github.com/mamachanko/cfpush) -
|
|
105
|
+
- [cfpush](https://github.com/mamachanko/cfpush) - Interactive Cloud Foundry tutorial.
|
|
106
106
|
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app.
|
|
107
|
-
- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read summaries.
|
|
108
|
-
- [garson](https://github.com/goliney/garson) - Build interactive config-based command-line interfaces.
|
|
109
|
-
- [git-contrib-calendar](https://github.com/giannisp/git-contrib-calendar) - Display a contributions calendar for any
|
|
110
|
-
- [gitgud](https://github.com/GitGud-org/GitGud) -
|
|
111
|
-
- [Autarky](https://github.com/pranshuchittora/autarky) - Find and delete old `node_modules` directories
|
|
112
|
-
- [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download and upload
|
|
107
|
+
- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read article summaries.
|
|
108
|
+
- [garson](https://github.com/goliney/garson) - Build interactive, config-based command-line interfaces.
|
|
109
|
+
- [git-contrib-calendar](https://github.com/giannisp/git-contrib-calendar) - Display a contributions calendar for any Git repository.
|
|
110
|
+
- [gitgud](https://github.com/GitGud-org/GitGud) - Interactive command-line GUI for Git.
|
|
111
|
+
- [Autarky](https://github.com/pranshuchittora/autarky) - Find and delete old `node_modules` directories to free up disk space.
|
|
112
|
+
- [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download and upload speeds.
|
|
113
113
|
- [tasuku](https://github.com/privatenumber/tasuku) - Minimal task runner.
|
|
114
|
-
- [mnswpr](https://github.com/mordv/mnswpr) - Minesweeper game.
|
|
114
|
+
- [mnswpr](https://github.com/mordv/mnswpr) - A Minesweeper game.
|
|
115
115
|
- [lrn](https://github.com/krychu/lrn) - Learning by repetition.
|
|
116
|
-
- [turdle](https://github.com/mynameisankit/turdle) - Wordle game.
|
|
117
|
-
- [Shopify CLI](https://github.com/Shopify/cli) - Build apps, themes, and storefronts for Shopify.
|
|
118
|
-
- [ToDesktop CLI](https://www.todesktop.com/electron) -
|
|
119
|
-
- [Walle](https://github.com/Pobepto/walle) -
|
|
120
|
-
- [Sudoku](https://github.com/mrozio13pl/sudoku-in-terminal) - Sudoku game.
|
|
121
|
-
- [Sea Trader](https://github.com/zyishai/sea-trader) - Taipan
|
|
116
|
+
- [turdle](https://github.com/mynameisankit/turdle) - A Wordle game.
|
|
117
|
+
- [Shopify CLI](https://github.com/Shopify/cli) - Build apps, themes, and storefronts for the Shopify platform.
|
|
118
|
+
- [ToDesktop CLI](https://www.todesktop.com/electron) - All-in-one platform for building Electron apps.
|
|
119
|
+
- [Walle](https://github.com/Pobepto/walle) - A full-featured crypto wallet for EVM networks.
|
|
120
|
+
- [Sudoku](https://github.com/mrozio13pl/sudoku-in-terminal) - A Sudoku game.
|
|
121
|
+
- [Sea Trader](https://github.com/zyishai/sea-trader) - A Taipan!-inspired trading simulator game.
|
|
122
122
|
- [srtd](https://github.com/t1mmen/srtd) - Live-reloading SQL templates for Supabase projects.
|
|
123
123
|
- [tweakcc](https://github.com/Piebald-AI/tweakcc) - Customize your Claude Code styling.
|
|
124
124
|
- [argonaut](https://github.com/darksworm/argonaut) - Manage Argo CD resources.
|
|
125
125
|
- [Qodo Command](https://github.com/qodo-ai/command) - Build, run, and manage AI agents.
|
|
126
126
|
|
|
127
|
+
*(PRs welcome. Append new entries at the end. Repos must have 100+ stars and showcase Ink beyond a basic list picker.)*
|
|
128
|
+
|
|
127
129
|
## Contents
|
|
128
130
|
|
|
129
131
|
- [Getting Started](#getting-started)
|
|
@@ -209,9 +211,9 @@ If you don't like transpiling files during development, you can use [import-jsx]
|
|
|
209
211
|
</p>
|
|
210
212
|
</details>
|
|
211
213
|
|
|
212
|
-
Ink uses [Yoga](https://github.com/facebook/yoga)
|
|
214
|
+
Ink 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.
|
|
213
215
|
It's important to remember that each element is a Flexbox container.
|
|
214
|
-
Think of it as if
|
|
216
|
+
Think of it as if every `<div>` in the browser had `display: flex`.
|
|
215
217
|
See [`<Box>`](#box) built-in component below for documentation on how to use Flexbox layouts in Ink.
|
|
216
218
|
Note that all text must be wrapped in a [`<Text>`](#text) component.
|
|
217
219
|
|
|
@@ -219,7 +221,7 @@ Note that all text must be wrapped in a [`<Text>`](#text) component.
|
|
|
219
221
|
|
|
220
222
|
### `<Text>`
|
|
221
223
|
|
|
222
|
-
This component can display text
|
|
224
|
+
This component can display text and change its style to make it bold, underlined, italic, or strikethrough.
|
|
223
225
|
|
|
224
226
|
```jsx
|
|
225
227
|
import {render, Text} from 'ink';
|
|
@@ -278,7 +280,7 @@ Same as `color` above, but for background.
|
|
|
278
280
|
Type: `boolean`\
|
|
279
281
|
Default: `false`
|
|
280
282
|
|
|
281
|
-
Dim the color (
|
|
283
|
+
Dim the color (make it less bright).
|
|
282
284
|
|
|
283
285
|
```jsx
|
|
284
286
|
<Text color="red" dimColor>
|
|
@@ -321,7 +323,7 @@ Make the text crossed with a line.
|
|
|
321
323
|
Type: `boolean`\
|
|
322
324
|
Default: `false`
|
|
323
325
|
|
|
324
|
-
|
|
326
|
+
Invert background and foreground colors.
|
|
325
327
|
|
|
326
328
|
```jsx
|
|
327
329
|
<Text inverse color="yellow">
|
|
@@ -337,9 +339,9 @@ Type: `string`\
|
|
|
337
339
|
Allowed values: `wrap` `truncate` `truncate-start` `truncate-middle` `truncate-end`\
|
|
338
340
|
Default: `wrap`
|
|
339
341
|
|
|
340
|
-
This property tells Ink to wrap or truncate text if its width is larger than container.
|
|
341
|
-
If `wrap` is passed (
|
|
342
|
-
If `truncate-*` is passed, Ink will truncate text instead,
|
|
342
|
+
This property tells Ink to wrap or truncate text if its width is larger than the container.
|
|
343
|
+
If `wrap` is passed (the default), Ink will wrap text and split it into multiple lines.
|
|
344
|
+
If `truncate-*` is passed, Ink will truncate text instead, resulting in one line of text with the rest cut off.
|
|
343
345
|
|
|
344
346
|
```jsx
|
|
345
347
|
<Box width={7}>
|
|
@@ -388,7 +390,7 @@ render(<Example />);
|
|
|
388
390
|
Type: `number` `string`
|
|
389
391
|
|
|
390
392
|
Width of the element in spaces.
|
|
391
|
-
You can also set it
|
|
393
|
+
You can also set it as a percentage, which will calculate the width based on the width of the parent element.
|
|
392
394
|
|
|
393
395
|
```jsx
|
|
394
396
|
<Box width={4}>
|
|
@@ -412,7 +414,7 @@ You can also set it in percent, which will calculate the width based on the widt
|
|
|
412
414
|
Type: `number` `string`
|
|
413
415
|
|
|
414
416
|
Height of the element in lines (rows).
|
|
415
|
-
You can also set it
|
|
417
|
+
You can also set it as a percentage, which will calculate the height based on the height of the parent element.
|
|
416
418
|
|
|
417
419
|
```jsx
|
|
418
420
|
<Box height={4}>
|
|
@@ -436,14 +438,14 @@ You can also set it in percent, which will calculate the height based on the hei
|
|
|
436
438
|
Type: `number`
|
|
437
439
|
|
|
438
440
|
Sets a minimum width of the element.
|
|
439
|
-
Percentages aren't supported yet
|
|
441
|
+
Percentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.
|
|
440
442
|
|
|
441
443
|
##### minHeight
|
|
442
444
|
|
|
443
445
|
Type: `number`
|
|
444
446
|
|
|
445
447
|
Sets a minimum height of the element.
|
|
446
|
-
Percentages aren't supported yet
|
|
448
|
+
Percentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.
|
|
447
449
|
|
|
448
450
|
#### Padding
|
|
449
451
|
|
|
@@ -574,7 +576,7 @@ Margin on all sides. Equivalent to setting `marginTop`, `marginBottom`, `marginL
|
|
|
574
576
|
Type: `number`\
|
|
575
577
|
Default: `0`
|
|
576
578
|
|
|
577
|
-
Size of the gap between an element's columns and rows.
|
|
579
|
+
Size of the gap between an element's columns and rows. A shorthand for `columnGap` and `rowGap`.
|
|
578
580
|
|
|
579
581
|
```jsx
|
|
580
582
|
<Box gap={1} width={3} flexWrap="wrap">
|
|
@@ -607,7 +609,7 @@ Size of the gap between an element's columns.
|
|
|
607
609
|
Type: `number`\
|
|
608
610
|
Default: `0`
|
|
609
611
|
|
|
610
|
-
Size of the gap between element's rows.
|
|
612
|
+
Size of the gap between an element's rows.
|
|
611
613
|
|
|
612
614
|
```jsx
|
|
613
615
|
<Box flexDirection="column" rowGap={1}>
|
|
@@ -898,7 +900,7 @@ Type: `string`\
|
|
|
898
900
|
Allowed values: `visible` `hidden`\
|
|
899
901
|
Default: `visible`
|
|
900
902
|
|
|
901
|
-
Behavior for an element's overflow in horizontal direction.
|
|
903
|
+
Behavior for an element's overflow in the horizontal direction.
|
|
902
904
|
|
|
903
905
|
##### overflowY
|
|
904
906
|
|
|
@@ -906,7 +908,7 @@ Type: `string`\
|
|
|
906
908
|
Allowed values: `visible` `hidden`\
|
|
907
909
|
Default: `visible`
|
|
908
910
|
|
|
909
|
-
Behavior for an element's overflow in vertical direction.
|
|
911
|
+
Behavior for an element's overflow in the vertical direction.
|
|
910
912
|
|
|
911
913
|
##### overflow
|
|
912
914
|
|
|
@@ -914,7 +916,7 @@ Type: `string`\
|
|
|
914
916
|
Allowed values: `visible` `hidden`\
|
|
915
917
|
Default: `visible`
|
|
916
918
|
|
|
917
|
-
|
|
919
|
+
A shortcut for setting `overflowX` and `overflowY` at the same time.
|
|
918
920
|
|
|
919
921
|
#### Borders
|
|
920
922
|
|
|
@@ -924,8 +926,8 @@ Type: `string`\
|
|
|
924
926
|
Allowed values: `single` `double` `round` `bold` `singleDouble` `doubleSingle` `classic` | `BoxStyle`
|
|
925
927
|
|
|
926
928
|
Add a border with a specified style.
|
|
927
|
-
If `borderStyle` is `undefined` (
|
|
928
|
-
Ink uses border styles from [`cli-boxes`](https://github.com/sindresorhus/cli-boxes) module.
|
|
929
|
+
If `borderStyle` is `undefined` (the default), no border will be added.
|
|
930
|
+
Ink uses border styles from the [`cli-boxes`](https://github.com/sindresorhus/cli-boxes) module.
|
|
929
931
|
|
|
930
932
|
```jsx
|
|
931
933
|
<Box flexDirection="column">
|
|
@@ -991,7 +993,7 @@ See example in [examples/borders](examples/borders/borders.tsx).
|
|
|
991
993
|
Type: `string`
|
|
992
994
|
|
|
993
995
|
Change border color.
|
|
994
|
-
|
|
996
|
+
A shorthand for setting `borderTopColor`, `borderRightColor`, `borderBottomColor`, and `borderLeftColor`.
|
|
995
997
|
|
|
996
998
|
```jsx
|
|
997
999
|
<Box borderStyle="round" borderColor="green">
|
|
@@ -1027,19 +1029,6 @@ Accepts the same values as [`color`](#color) in `<Text>` component.
|
|
|
1027
1029
|
</Box>
|
|
1028
1030
|
```
|
|
1029
1031
|
|
|
1030
|
-
##### borderRightColor
|
|
1031
|
-
|
|
1032
|
-
Type: `string`
|
|
1033
|
-
|
|
1034
|
-
Change right border color.
|
|
1035
|
-
Accepts the same values as [`color`](#color) in `<Text>` component.
|
|
1036
|
-
|
|
1037
|
-
```jsx
|
|
1038
|
-
<Box borderStyle="round" borderRightColor="green">
|
|
1039
|
-
<Text>Hello world</Text>
|
|
1040
|
-
</Box>
|
|
1041
|
-
```
|
|
1042
|
-
|
|
1043
1032
|
##### borderBottomColor
|
|
1044
1033
|
|
|
1045
1034
|
Type: `string`
|
|
@@ -1072,7 +1061,7 @@ Type: `boolean`\
|
|
|
1072
1061
|
Default: `false`
|
|
1073
1062
|
|
|
1074
1063
|
Dim the border color.
|
|
1075
|
-
|
|
1064
|
+
A shorthand for setting `borderTopDimColor`, `borderBottomDimColor`, `borderLeftDimColor`, and `borderRightDimColor`.
|
|
1076
1065
|
|
|
1077
1066
|
```jsx
|
|
1078
1067
|
<Box borderStyle="round" borderDimColor>
|
|
@@ -1242,7 +1231,7 @@ World
|
|
|
1242
1231
|
### `<Spacer>`
|
|
1243
1232
|
|
|
1244
1233
|
A flexible space that expands along the major axis of its containing layout.
|
|
1245
|
-
It's useful as a shortcut for filling all the available
|
|
1234
|
+
It's useful as a shortcut for filling all the available space between elements.
|
|
1246
1235
|
|
|
1247
1236
|
For 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.
|
|
1248
1237
|
|
|
@@ -1260,8 +1249,8 @@ const Example = () => (
|
|
|
1260
1249
|
render(<Example />);
|
|
1261
1250
|
```
|
|
1262
1251
|
|
|
1263
|
-
In a vertical flex direction (`column`), it will position "Top"
|
|
1264
|
-
Note
|
|
1252
|
+
In a vertical flex direction (`column`), it will position "Top" at the top of the container and push "Bottom" to the bottom.
|
|
1253
|
+
Note that the container needs to be tall enough to see this in effect.
|
|
1265
1254
|
|
|
1266
1255
|
```jsx
|
|
1267
1256
|
import {render, Box, Text, Spacer} from 'ink';
|
|
@@ -1281,14 +1270,14 @@ render(<Example />);
|
|
|
1281
1270
|
|
|
1282
1271
|
`<Static>` component permanently renders its output above everything else.
|
|
1283
1272
|
It's useful for displaying activity like completed tasks or logs - things that
|
|
1284
|
-
|
|
1273
|
+
don't change after they're rendered (hence the name "Static").
|
|
1285
1274
|
|
|
1286
|
-
It's preferred to use `<Static>` for use cases like these
|
|
1287
|
-
or control the
|
|
1275
|
+
It's preferred to use `<Static>` for use cases like these when you can't know
|
|
1276
|
+
or control the number of items that need to be rendered.
|
|
1288
1277
|
|
|
1289
1278
|
For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display
|
|
1290
1279
|
a list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it
|
|
1291
|
-
to display a list of generated pages
|
|
1280
|
+
to display a list of generated pages while still displaying a live progress bar.
|
|
1292
1281
|
|
|
1293
1282
|
```jsx
|
|
1294
1283
|
import React, {useState, useEffect} from 'react';
|
|
@@ -1345,8 +1334,8 @@ const Example = () => {
|
|
|
1345
1334
|
render(<Example />);
|
|
1346
1335
|
```
|
|
1347
1336
|
|
|
1348
|
-
**Note:** `<Static>` only renders new items in `items` prop and ignores items
|
|
1349
|
-
that were previously rendered. This means that when you add new items to `items`
|
|
1337
|
+
**Note:** `<Static>` only renders new items in the `items` prop and ignores items
|
|
1338
|
+
that were previously rendered. This means that when you add new items to the `items`
|
|
1350
1339
|
array, changes you make to previous items will not trigger a rerender.
|
|
1351
1340
|
|
|
1352
1341
|
See [examples/static](examples/static/static.tsx) for an example usage of `<Static>` component.
|
|
@@ -1355,7 +1344,7 @@ See [examples/static](examples/static/static.tsx) for an example usage of `<Stat
|
|
|
1355
1344
|
|
|
1356
1345
|
Type: `Array`
|
|
1357
1346
|
|
|
1358
|
-
Array of items of any type to render using
|
|
1347
|
+
Array of items of any type to render using the function you pass as a component child.
|
|
1359
1348
|
|
|
1360
1349
|
#### style
|
|
1361
1350
|
|
|
@@ -1374,11 +1363,11 @@ See [`<Box>`](#box) for supported properties.
|
|
|
1374
1363
|
|
|
1375
1364
|
Type: `Function`
|
|
1376
1365
|
|
|
1377
|
-
Function that is called to render every item in `items` array.
|
|
1378
|
-
|
|
1366
|
+
Function that is called to render every item in the `items` array.
|
|
1367
|
+
The first argument is the item itself, and the second argument is the index of that item in the
|
|
1379
1368
|
`items` array.
|
|
1380
1369
|
|
|
1381
|
-
Note that `key` must be assigned to the root component.
|
|
1370
|
+
Note that a `key` must be assigned to the root component.
|
|
1382
1371
|
|
|
1383
1372
|
```jsx
|
|
1384
1373
|
<Static items={['a', 'b', 'c']}>
|
|
@@ -1397,12 +1386,12 @@ Note that `key` must be assigned to the root component.
|
|
|
1397
1386
|
|
|
1398
1387
|
### `<Transform>`
|
|
1399
1388
|
|
|
1400
|
-
Transform a string representation of React components before they
|
|
1401
|
-
For 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).
|
|
1402
|
-
These use cases can't accept React nodes as input
|
|
1403
|
-
That's what `<Transform>` component does
|
|
1389
|
+
Transform a string representation of React components before they're written to output.
|
|
1390
|
+
For 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).
|
|
1391
|
+
These use cases can't accept React nodes as input; they expect a string.
|
|
1392
|
+
That's what the `<Transform>` component does: it gives you an output string of its child components and lets you transform it in any way.
|
|
1404
1393
|
|
|
1405
|
-
**Note:** `<Transform>` must be applied only to `<Text>` children components and shouldn't change the dimensions of the output
|
|
1394
|
+
**Note:** `<Transform>` must be applied only to `<Text>` children components and shouldn't change the dimensions of the output; otherwise, the layout will be incorrect.
|
|
1406
1395
|
|
|
1407
1396
|
```jsx
|
|
1408
1397
|
import {render, Transform} from 'ink';
|
|
@@ -1416,7 +1405,7 @@ const Example = () => (
|
|
|
1416
1405
|
render(<Example />);
|
|
1417
1406
|
```
|
|
1418
1407
|
|
|
1419
|
-
Since `transform` function converts all characters to
|
|
1408
|
+
Since the `transform` function converts all characters to uppercase, the final output rendered to the terminal will be "HELLO WORLD", not "Hello World".
|
|
1420
1409
|
|
|
1421
1410
|
When the output wraps to multiple lines, it can be helpful to know which line is being processed.
|
|
1422
1411
|
|
|
@@ -1456,8 +1445,8 @@ render(
|
|
|
1456
1445
|
|
|
1457
1446
|
Type: `Function`
|
|
1458
1447
|
|
|
1459
|
-
Function
|
|
1460
|
-
It accepts children and must return transformed children
|
|
1448
|
+
Function that transforms children output.
|
|
1449
|
+
It accepts children and must return transformed children as well.
|
|
1461
1450
|
|
|
1462
1451
|
##### children
|
|
1463
1452
|
|
|
@@ -1469,16 +1458,16 @@ Output of child components.
|
|
|
1469
1458
|
|
|
1470
1459
|
Type: `number`
|
|
1471
1460
|
|
|
1472
|
-
The zero-indexed line number of the line currently being transformed.
|
|
1461
|
+
The zero-indexed line number of the line that's currently being transformed.
|
|
1473
1462
|
|
|
1474
1463
|
## Hooks
|
|
1475
1464
|
|
|
1476
1465
|
### useInput(inputHandler, options?)
|
|
1477
1466
|
|
|
1478
1467
|
This hook is used for handling user input.
|
|
1479
|
-
It's a more convenient alternative to using `useStdin` and listening
|
|
1480
|
-
The callback you pass to `useInput` is called for each character when user enters any input.
|
|
1481
|
-
However, if 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`.
|
|
1468
|
+
It's a more convenient alternative to using `useStdin` and listening for `data` events.
|
|
1469
|
+
The callback you pass to `useInput` is called for each character when the user enters any input.
|
|
1470
|
+
However, 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`.
|
|
1482
1471
|
You can find a full example of using `useInput` at [examples/use-input](examples/use-input/use-input.tsx).
|
|
1483
1472
|
|
|
1484
1473
|
```jsx
|
|
@@ -1529,7 +1518,7 @@ Type: `boolean`\
|
|
|
1529
1518
|
Default: `false`
|
|
1530
1519
|
|
|
1531
1520
|
If an arrow key was pressed, the corresponding property will be `true`.
|
|
1532
|
-
For example, if user presses left arrow key, `key.leftArrow` equals `true`.
|
|
1521
|
+
For example, if the user presses the left arrow key, `key.leftArrow` equals `true`.
|
|
1533
1522
|
|
|
1534
1523
|
###### key.return
|
|
1535
1524
|
|
|
@@ -1587,8 +1576,8 @@ Delete key was pressed.
|
|
|
1587
1576
|
Type: `boolean`\
|
|
1588
1577
|
Default: `false`
|
|
1589
1578
|
|
|
1590
|
-
If Page Up or Page Down key was pressed, the corresponding property will be `true`.
|
|
1591
|
-
For example, if user presses Page Down, `key.pageDown` equals `true`.
|
|
1579
|
+
If the Page Up or Page Down key was pressed, the corresponding property will be `true`.
|
|
1580
|
+
For example, if the user presses Page Down, `key.pageDown` equals `true`.
|
|
1592
1581
|
|
|
1593
1582
|
###### key.meta
|
|
1594
1583
|
|
|
@@ -1611,7 +1600,7 @@ Useful when there are multiple `useInput` hooks used at once to avoid handling t
|
|
|
1611
1600
|
|
|
1612
1601
|
### useApp()
|
|
1613
1602
|
|
|
1614
|
-
`useApp` is a React hook
|
|
1603
|
+
`useApp` is a React hook that exposes a method to manually exit the app (unmount).
|
|
1615
1604
|
|
|
1616
1605
|
#### exit(error?)
|
|
1617
1606
|
|
|
@@ -1644,14 +1633,14 @@ const Example = () => {
|
|
|
1644
1633
|
|
|
1645
1634
|
### useStdin()
|
|
1646
1635
|
|
|
1647
|
-
`useStdin` is a React hook
|
|
1636
|
+
`useStdin` is a React hook that exposes the stdin stream.
|
|
1648
1637
|
|
|
1649
1638
|
#### stdin
|
|
1650
1639
|
|
|
1651
1640
|
Type: `stream.Readable`\
|
|
1652
1641
|
Default: `process.stdin`
|
|
1653
1642
|
|
|
1654
|
-
|
|
1643
|
+
The stdin stream passed to `render()` in `options.stdin`, or `process.stdin` by default.
|
|
1655
1644
|
Useful if your app needs to handle user input.
|
|
1656
1645
|
|
|
1657
1646
|
```js
|
|
@@ -1718,7 +1707,7 @@ const Example = () => {
|
|
|
1718
1707
|
|
|
1719
1708
|
### useStdout()
|
|
1720
1709
|
|
|
1721
|
-
`useStdout` is a React hook
|
|
1710
|
+
`useStdout` is a React hook that exposes the stdout stream where Ink renders your app.
|
|
1722
1711
|
|
|
1723
1712
|
#### stdout
|
|
1724
1713
|
|
|
@@ -1737,9 +1726,9 @@ const Example = () => {
|
|
|
1737
1726
|
|
|
1738
1727
|
#### write(data)
|
|
1739
1728
|
|
|
1740
|
-
Write any string to stdout
|
|
1741
|
-
It's useful when you want to display
|
|
1742
|
-
It's similar to `<Static>`, except it can't accept components
|
|
1729
|
+
Write any string to stdout while preserving Ink's output.
|
|
1730
|
+
It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two.
|
|
1731
|
+
It's similar to `<Static>`, except it can't accept components; it only works with strings.
|
|
1743
1732
|
|
|
1744
1733
|
##### data
|
|
1745
1734
|
|
|
@@ -1766,7 +1755,7 @@ See additional usage example in [examples/use-stdout](examples/use-stdout/use-st
|
|
|
1766
1755
|
|
|
1767
1756
|
### useStderr()
|
|
1768
1757
|
|
|
1769
|
-
`useStderr` is a React hook
|
|
1758
|
+
`useStderr` is a React hook that exposes the stderr stream.
|
|
1770
1759
|
|
|
1771
1760
|
#### stderr
|
|
1772
1761
|
|
|
@@ -1787,10 +1776,10 @@ const Example = () => {
|
|
|
1787
1776
|
|
|
1788
1777
|
#### write(data)
|
|
1789
1778
|
|
|
1790
|
-
Write any string to stderr
|
|
1779
|
+
Write any string to stderr while preserving Ink's output.
|
|
1791
1780
|
|
|
1792
|
-
It's useful when you want to display
|
|
1793
|
-
It's similar to `<Static>`, except it can't accept components
|
|
1781
|
+
It's useful when you want to display external information outside of Ink's rendering and ensure there's no conflict between the two.
|
|
1782
|
+
It's similar to `<Static>`, except it can't accept components; it only works with strings.
|
|
1794
1783
|
|
|
1795
1784
|
##### data
|
|
1796
1785
|
|
|
@@ -1815,9 +1804,9 @@ const Example = () => {
|
|
|
1815
1804
|
|
|
1816
1805
|
### useFocus(options?)
|
|
1817
1806
|
|
|
1818
|
-
|
|
1819
|
-
If there are multiple components that execute `useFocus` hook, focus will be given to them in the order
|
|
1820
|
-
This hook returns an object with `isFocused` boolean property, which determines
|
|
1807
|
+
A 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.
|
|
1808
|
+
If there are multiple components that execute the `useFocus` hook, focus will be given to them in the order in which these components are rendered.
|
|
1809
|
+
This hook returns an object with an `isFocused` boolean property, which determines whether this component is focused.
|
|
1821
1810
|
|
|
1822
1811
|
#### options
|
|
1823
1812
|
|
|
@@ -1826,7 +1815,7 @@ This hook returns an object with `isFocused` boolean property, which determines
|
|
|
1826
1815
|
Type: `boolean`\
|
|
1827
1816
|
Default: `false`
|
|
1828
1817
|
|
|
1829
|
-
Auto
|
|
1818
|
+
Auto-focus this component if there's no active (focused) component right now.
|
|
1830
1819
|
|
|
1831
1820
|
##### isActive
|
|
1832
1821
|
|
|
@@ -1841,7 +1830,7 @@ This is useful for inputs that are temporarily disabled.
|
|
|
1841
1830
|
Type: `string`\
|
|
1842
1831
|
Required: `false`
|
|
1843
1832
|
|
|
1844
|
-
Set a component's focus ID, which can be used to programmatically focus the component. This is useful for large interfaces with many focusable elements
|
|
1833
|
+
Set 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.
|
|
1845
1834
|
|
|
1846
1835
|
```jsx
|
|
1847
1836
|
import {render, useFocus, Text} from 'ink';
|
|
@@ -1865,7 +1854,7 @@ This hook exposes methods to enable or disable focus management for all componen
|
|
|
1865
1854
|
|
|
1866
1855
|
Enable focus management for all components.
|
|
1867
1856
|
|
|
1868
|
-
**Note:** You don't need to call this method manually
|
|
1857
|
+
**Note:** You don't need to call this method manually unless you've disabled focus management. Focus management is enabled by default.
|
|
1869
1858
|
|
|
1870
1859
|
```js
|
|
1871
1860
|
import {useFocusManager} from 'ink';
|
|
@@ -1884,7 +1873,7 @@ const Example = () => {
|
|
|
1884
1873
|
#### disableFocus()
|
|
1885
1874
|
|
|
1886
1875
|
Disable focus management for all components.
|
|
1887
|
-
|
|
1876
|
+
The currently active component (if there's one) will lose its focus.
|
|
1888
1877
|
|
|
1889
1878
|
```js
|
|
1890
1879
|
import {useFocusManager} from 'ink';
|
|
@@ -1904,7 +1893,7 @@ const Example = () => {
|
|
|
1904
1893
|
|
|
1905
1894
|
Switch focus to the next focusable component.
|
|
1906
1895
|
If there's no active component right now, focus will be given to the first focusable component.
|
|
1907
|
-
If active component is the last in the list of focusable components, focus will be switched to the first
|
|
1896
|
+
If the active component is the last in the list of focusable components, focus will be switched to the first focusable component.
|
|
1908
1897
|
|
|
1909
1898
|
**Note:** Ink calls this method when user presses <kbd>Tab</kbd>.
|
|
1910
1899
|
|
|
@@ -1926,7 +1915,7 @@ const Example = () => {
|
|
|
1926
1915
|
|
|
1927
1916
|
Switch focus to the previous focusable component.
|
|
1928
1917
|
If there's no active component right now, focus will be given to the first focusable component.
|
|
1929
|
-
If active component is the first in the list of focusable components, focus will be switched to the last component.
|
|
1918
|
+
If the active component is the first in the list of focusable components, focus will be switched to the last focusable component.
|
|
1930
1919
|
|
|
1931
1920
|
**Note:** Ink calls this method when user presses <kbd>Shift</kbd>+<kbd>Tab</kbd>.
|
|
1932
1921
|
|
|
@@ -1972,7 +1961,7 @@ const Example = () => {
|
|
|
1972
1961
|
|
|
1973
1962
|
### useIsScreenReaderEnabled()
|
|
1974
1963
|
|
|
1975
|
-
Returns whether screen reader is enabled. This is useful when you want to render
|
|
1964
|
+
Returns whether a screen reader is enabled. This is useful when you want to render different output for screen readers.
|
|
1976
1965
|
|
|
1977
1966
|
```jsx
|
|
1978
1967
|
import {useIsScreenReaderEnabled, Text} from 'ink';
|
|
@@ -2025,26 +2014,36 @@ Input stream where app will listen for input.
|
|
|
2025
2014
|
Type: `boolean`\
|
|
2026
2015
|
Default: `true`
|
|
2027
2016
|
|
|
2028
|
-
Configure whether Ink should listen
|
|
2029
|
-
This 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 process is expected to handle it manually.
|
|
2017
|
+
Configure whether Ink should listen for Ctrl+C keyboard input and exit the app.
|
|
2018
|
+
This 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.
|
|
2030
2019
|
|
|
2031
2020
|
###### patchConsole
|
|
2032
2021
|
|
|
2033
2022
|
Type: `boolean`\
|
|
2034
2023
|
Default: `true`
|
|
2035
2024
|
|
|
2036
|
-
Patch console methods to ensure console output doesn't mix with Ink output.
|
|
2037
|
-
When any of `console.*` methods are called (like `console.log()`), Ink intercepts their output, clears main output, renders output from the console method and then rerenders main output again.
|
|
2038
|
-
That way both are visible and
|
|
2025
|
+
Patch console methods to ensure console output doesn't mix with Ink's output.
|
|
2026
|
+
When 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.
|
|
2027
|
+
That way, both are visible and don't overlap each other.
|
|
2039
2028
|
|
|
2040
|
-
This 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
|
|
2029
|
+
This 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.
|
|
2041
2030
|
|
|
2042
2031
|
###### debug
|
|
2043
2032
|
|
|
2044
2033
|
Type: `boolean`\
|
|
2045
2034
|
Default: `false`
|
|
2046
2035
|
|
|
2047
|
-
If `true`, each update will be rendered as
|
|
2036
|
+
If `true`, each update will be rendered as separate output, without replacing the previous one.
|
|
2037
|
+
|
|
2038
|
+
###### maxFps
|
|
2039
|
+
|
|
2040
|
+
Type: `number`\
|
|
2041
|
+
Default: `30`
|
|
2042
|
+
|
|
2043
|
+
Maximum frames per second for render updates.
|
|
2044
|
+
This controls how frequently the UI can update to prevent excessive re-rendering.
|
|
2045
|
+
Higher values allow more frequent updates but may impact performance.
|
|
2046
|
+
Setting it to a lower value may be useful for components that update very frequently, to reduce CPU usage.
|
|
2048
2047
|
|
|
2049
2048
|
#### Instance
|
|
2050
2049
|
|
|
@@ -2052,7 +2051,7 @@ This is the object that `render()` returns.
|
|
|
2052
2051
|
|
|
2053
2052
|
##### rerender(tree)
|
|
2054
2053
|
|
|
2055
|
-
Replace previous root node with a new one or update props of the current root node.
|
|
2054
|
+
Replace the previous root node with a new one or update props of the current root node.
|
|
2056
2055
|
|
|
2057
2056
|
###### tree
|
|
2058
2057
|
|
|
@@ -2079,7 +2078,7 @@ unmount();
|
|
|
2079
2078
|
|
|
2080
2079
|
##### waitUntilExit()
|
|
2081
2080
|
|
|
2082
|
-
Returns a promise
|
|
2081
|
+
Returns a promise that resolves when the app is unmounted.
|
|
2083
2082
|
|
|
2084
2083
|
```jsx
|
|
2085
2084
|
const {unmount, waitUntilExit} = render(<MyApp />);
|
|
@@ -2101,16 +2100,16 @@ clear();
|
|
|
2101
2100
|
#### measureElement(ref)
|
|
2102
2101
|
|
|
2103
2102
|
Measure the dimensions of a particular `<Box>` element.
|
|
2104
|
-
|
|
2105
|
-
This function is useful when your component needs to know the amount of available space it has. You
|
|
2103
|
+
Returns an object with `width` and `height` properties.
|
|
2104
|
+
This 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.
|
|
2106
2105
|
|
|
2107
|
-
**Note:** `measureElement()` returns correct results only after the initial render, when layout has been calculated. Until then, `width` and `height` equal
|
|
2106
|
+
**Note:** `measureElement()` returns correct results only after the initial render, when the layout has been calculated. Until then, `width` and `height` equal zero. It's recommended to call `measureElement()` in a `useEffect` hook, which fires after the component has rendered.
|
|
2108
2107
|
|
|
2109
2108
|
##### ref
|
|
2110
2109
|
|
|
2111
2110
|
Type: `MutableRef`
|
|
2112
2111
|
|
|
2113
|
-
A reference to a `<Box>` element captured with
|
|
2112
|
+
A reference to a `<Box>` element captured with the `ref` property.
|
|
2114
2113
|
See [Refs](https://reactjs.org/docs/refs-and-the-dom.html) for more information on how to capture references.
|
|
2115
2114
|
|
|
2116
2115
|
```jsx
|
|
@@ -2158,7 +2157,7 @@ Check out [ink-testing-library](https://github.com/vadimdemedes/ink-testing-libr
|
|
|
2158
2157
|
|
|
2159
2158
|

|
|
2160
2159
|
|
|
2161
|
-
Ink supports [React Devtools](https://github.com/facebook/react/tree/master/packages/react-devtools) out
|
|
2160
|
+
Ink 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:
|
|
2162
2161
|
|
|
2163
2162
|
```sh
|
|
2164
2163
|
DEV=true my-cli
|
|
@@ -2170,14 +2169,14 @@ Then, start React Devtools itself:
|
|
|
2170
2169
|
npx react-devtools
|
|
2171
2170
|
```
|
|
2172
2171
|
|
|
2173
|
-
After it starts
|
|
2172
|
+
After it starts, you should see the component tree of your CLI.
|
|
2174
2173
|
You can even inspect and change the props of components, and see the results immediately in the CLI, without restarting it.
|
|
2175
2174
|
|
|
2176
2175
|
**Note**: You must manually quit your CLI via <kbd>Ctrl</kbd>+<kbd>C</kbd> after you're done testing.
|
|
2177
2176
|
|
|
2178
2177
|
## Screen Reader Support
|
|
2179
2178
|
|
|
2180
|
-
Ink has
|
|
2179
|
+
Ink has basic support for screen readers.
|
|
2181
2180
|
|
|
2182
2181
|
To enable it, you can either pass the `isScreenReaderEnabled` option to the `render` function or set the `INK_SCREEN_READER` environment variable to `true`.
|
|
2183
2182
|
|
|
@@ -2203,7 +2202,7 @@ Ink will generate the following output for screen readers:
|
|
|
2203
2202
|
(checked) checkbox: Accept terms and conditions
|
|
2204
2203
|
```
|
|
2205
2204
|
|
|
2206
|
-
You can also provide a custom label for screen readers
|
|
2205
|
+
You can also provide a custom label for screen readers if you want to render something different for them.
|
|
2207
2206
|
|
|
2208
2207
|
For example, if you are building a progress bar, you can use `aria-label` to provide a more descriptive label for screen readers.
|
|
2209
2208
|
|
|
@@ -2214,13 +2213,13 @@ For example, if you are building a progress bar, you can use `aria-label` to pro
|
|
|
2214
2213
|
</Box>
|
|
2215
2214
|
```
|
|
2216
2215
|
|
|
2217
|
-
In the example above, screen reader will read "Progress: 50%"
|
|
2216
|
+
In the example above, the screen reader will read "Progress: 50%" instead of "50%".
|
|
2218
2217
|
|
|
2219
2218
|
### `aria-label`
|
|
2220
2219
|
|
|
2221
2220
|
Type: `string`
|
|
2222
2221
|
|
|
2223
|
-
|
|
2222
|
+
A label for the element for screen readers.
|
|
2224
2223
|
|
|
2225
2224
|
### `aria-hidden`
|
|
2226
2225
|
|
|
@@ -2233,7 +2232,7 @@ Hide the element from screen readers.
|
|
|
2233
2232
|
|
|
2234
2233
|
Type: `string`
|
|
2235
2234
|
|
|
2236
|
-
|
|
2235
|
+
The role of the element.
|
|
2237
2236
|
|
|
2238
2237
|
Supported values:
|
|
2239
2238
|
- `button`
|
|
@@ -2255,7 +2254,7 @@ Supported values:
|
|
|
2255
2254
|
|
|
2256
2255
|
Type: `object`
|
|
2257
2256
|
|
|
2258
|
-
|
|
2257
|
+
The state of the element.
|
|
2259
2258
|
|
|
2260
2259
|
Supported values:
|
|
2261
2260
|
- `checked` (boolean)
|
|
@@ -2269,8 +2268,8 @@ When building custom components, it's important to keep accessibility in mind. W
|
|
|
2269
2268
|
|
|
2270
2269
|
### General Principles
|
|
2271
2270
|
|
|
2272
|
-
- **Provide screen reader-friendly output:** Use the `useIsScreenReaderEnabled` hook to detect if a screen reader is active. You can then render
|
|
2273
|
-
- **Leverage ARIA props:** For components that have a specific role (e.g., a checkbox or
|
|
2271
|
+
- **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.
|
|
2272
|
+
- **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 `<Box>` and `<Text>` to provide semantic meaning to screen readers.
|
|
2274
2273
|
|
|
2275
2274
|
For a practical example of building an accessible component, see the [ARIA example](/examples/aria/aria.tsx).
|
|
2276
2275
|
|
|
@@ -2291,13 +2290,14 @@ For a practical example of building an accessible component, see the [ARIA examp
|
|
|
2291
2290
|
- [ink-table](https://github.com/maticzav/ink-table) - Table.
|
|
2292
2291
|
- [ink-ascii](https://github.com/hexrcs/ink-ascii) - Awesome text component with more font choices, based on Figlet.
|
|
2293
2292
|
- [ink-markdown](https://github.com/cameronhunter/ink-markdown) - Render syntax highlighted Markdown.
|
|
2294
|
-
- [ink-quicksearch-input](https://github.com/Eximchain/ink-quicksearch-input) - Select component with fast quicksearch-like navigation.
|
|
2293
|
+
- [ink-quicksearch-input](https://github.com/Eximchain/ink-quicksearch-input) - Select component with fast, quicksearch-like navigation.
|
|
2295
2294
|
- [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input.
|
|
2296
2295
|
- [ink-syntax-highlight](https://github.com/vsashyn/ink-syntax-highlight) - Code syntax highlighting.
|
|
2297
2296
|
- [ink-form](https://github.com/lukasbach/ink-form) - Form.
|
|
2298
2297
|
- [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list.
|
|
2299
2298
|
- [ink-spawn](https://github.com/kraenhansen/ink-spawn) - Spawn child processes.
|
|
2300
|
-
- [ink-titled-box](https://github.com/mishieck/ink-titled-box) - Box with title.
|
|
2299
|
+
- [ink-titled-box](https://github.com/mishieck/ink-titled-box) - Box with a title.
|
|
2300
|
+
- [ink-chart](https://github.com/pppp606/ink-chart) - Sparkline and bar chart.
|
|
2301
2301
|
|
|
2302
2302
|
## Useful Hooks
|
|
2303
2303
|
|
|
@@ -2313,17 +2313,17 @@ npm run example examples/[example name]
|
|
|
2313
2313
|
```
|
|
2314
2314
|
|
|
2315
2315
|
- [Jest](examples/jest/jest.tsx) - Implementation of basic Jest UI.
|
|
2316
|
-
- [Counter](examples/counter/counter.tsx) -
|
|
2316
|
+
- [Counter](examples/counter/counter.tsx) - A simple counter that increments every 100ms.
|
|
2317
2317
|
- [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).
|
|
2318
|
-
- [Borders](examples/borders/borders.tsx) - Add borders to `<Box>` component.
|
|
2318
|
+
- [Borders](examples/borders/borders.tsx) - Add borders to the `<Box>` component.
|
|
2319
2319
|
- [Suspense](examples/suspense/suspense.tsx) - Use React Suspense.
|
|
2320
|
-
- [Table](examples/table/table.tsx) -
|
|
2321
|
-
- [Focus management](examples/use-focus/use-focus.tsx) - Use `useFocus` hook to manage focus between components.
|
|
2322
|
-
- [User input](examples/use-input/use-input.tsx) - Listen
|
|
2323
|
-
- [Write to stdout](examples/use-stdout/use-stdout.tsx) - Write to stdout bypassing main Ink output.
|
|
2324
|
-
- [Write to stderr](examples/use-stderr/use-stderr.tsx) - Write to stderr bypassing main Ink output.
|
|
2325
|
-
- [Static](examples/static/static.tsx) - Use `<Static>` to render permanent output.
|
|
2326
|
-
- [Child process](examples/subprocess-output) -
|
|
2320
|
+
- [Table](examples/table/table.tsx) - Renders a table with multiple columns and rows.
|
|
2321
|
+
- [Focus management](examples/use-focus/use-focus.tsx) - Use the `useFocus` hook to manage focus between components.
|
|
2322
|
+
- [User input](examples/use-input/use-input.tsx) - Listen for user input.
|
|
2323
|
+
- [Write to stdout](examples/use-stdout/use-stdout.tsx) - Write to stdout, bypassing main Ink output.
|
|
2324
|
+
- [Write to stderr](examples/use-stderr/use-stderr.tsx) - Write to stderr, bypassing main Ink output.
|
|
2325
|
+
- [Static](examples/static/static.tsx) - Use the `<Static>` component to render permanent output.
|
|
2326
|
+
- [Child process](examples/subprocess-output) - Renders output from a child process.
|
|
2327
2327
|
|
|
2328
2328
|
## Maintainers
|
|
2329
2329
|
|