ink 6.2.2 → 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-node-to-output.js +1 -3
- package/build/render-node-to-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 -4
- package/readme.md +154 -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,59 +69,62 @@ 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
|
+
- [Qodo Command](https://github.com/qodo-ai/command) - Build, run, and manage AI agents.
|
|
126
|
+
|
|
127
|
+
*(PRs welcome. Append new entries at the end. Repos must have 100+ stars and showcase Ink beyond a basic list picker.)*
|
|
125
128
|
|
|
126
129
|
## Contents
|
|
127
130
|
|
|
@@ -208,9 +211,9 @@ If you don't like transpiling files during development, you can use [import-jsx]
|
|
|
208
211
|
</p>
|
|
209
212
|
</details>
|
|
210
213
|
|
|
211
|
-
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.
|
|
212
215
|
It's important to remember that each element is a Flexbox container.
|
|
213
|
-
Think of it as if
|
|
216
|
+
Think of it as if every `<div>` in the browser had `display: flex`.
|
|
214
217
|
See [`<Box>`](#box) built-in component below for documentation on how to use Flexbox layouts in Ink.
|
|
215
218
|
Note that all text must be wrapped in a [`<Text>`](#text) component.
|
|
216
219
|
|
|
@@ -218,7 +221,7 @@ Note that all text must be wrapped in a [`<Text>`](#text) component.
|
|
|
218
221
|
|
|
219
222
|
### `<Text>`
|
|
220
223
|
|
|
221
|
-
This component can display text
|
|
224
|
+
This component can display text and change its style to make it bold, underlined, italic, or strikethrough.
|
|
222
225
|
|
|
223
226
|
```jsx
|
|
224
227
|
import {render, Text} from 'ink';
|
|
@@ -277,7 +280,7 @@ Same as `color` above, but for background.
|
|
|
277
280
|
Type: `boolean`\
|
|
278
281
|
Default: `false`
|
|
279
282
|
|
|
280
|
-
Dim the color (
|
|
283
|
+
Dim the color (make it less bright).
|
|
281
284
|
|
|
282
285
|
```jsx
|
|
283
286
|
<Text color="red" dimColor>
|
|
@@ -320,7 +323,7 @@ Make the text crossed with a line.
|
|
|
320
323
|
Type: `boolean`\
|
|
321
324
|
Default: `false`
|
|
322
325
|
|
|
323
|
-
|
|
326
|
+
Invert background and foreground colors.
|
|
324
327
|
|
|
325
328
|
```jsx
|
|
326
329
|
<Text inverse color="yellow">
|
|
@@ -336,9 +339,9 @@ Type: `string`\
|
|
|
336
339
|
Allowed values: `wrap` `truncate` `truncate-start` `truncate-middle` `truncate-end`\
|
|
337
340
|
Default: `wrap`
|
|
338
341
|
|
|
339
|
-
This property tells Ink to wrap or truncate text if its width is larger than container.
|
|
340
|
-
If `wrap` is passed (
|
|
341
|
-
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.
|
|
342
345
|
|
|
343
346
|
```jsx
|
|
344
347
|
<Box width={7}>
|
|
@@ -387,7 +390,7 @@ render(<Example />);
|
|
|
387
390
|
Type: `number` `string`
|
|
388
391
|
|
|
389
392
|
Width of the element in spaces.
|
|
390
|
-
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.
|
|
391
394
|
|
|
392
395
|
```jsx
|
|
393
396
|
<Box width={4}>
|
|
@@ -411,7 +414,7 @@ You can also set it in percent, which will calculate the width based on the widt
|
|
|
411
414
|
Type: `number` `string`
|
|
412
415
|
|
|
413
416
|
Height of the element in lines (rows).
|
|
414
|
-
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.
|
|
415
418
|
|
|
416
419
|
```jsx
|
|
417
420
|
<Box height={4}>
|
|
@@ -435,14 +438,14 @@ You can also set it in percent, which will calculate the height based on the hei
|
|
|
435
438
|
Type: `number`
|
|
436
439
|
|
|
437
440
|
Sets a minimum width of the element.
|
|
438
|
-
Percentages aren't supported yet
|
|
441
|
+
Percentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.
|
|
439
442
|
|
|
440
443
|
##### minHeight
|
|
441
444
|
|
|
442
445
|
Type: `number`
|
|
443
446
|
|
|
444
447
|
Sets a minimum height of the element.
|
|
445
|
-
Percentages aren't supported yet
|
|
448
|
+
Percentages aren't supported yet; see https://github.com/facebook/yoga/issues/872.
|
|
446
449
|
|
|
447
450
|
#### Padding
|
|
448
451
|
|
|
@@ -573,7 +576,7 @@ Margin on all sides. Equivalent to setting `marginTop`, `marginBottom`, `marginL
|
|
|
573
576
|
Type: `number`\
|
|
574
577
|
Default: `0`
|
|
575
578
|
|
|
576
|
-
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`.
|
|
577
580
|
|
|
578
581
|
```jsx
|
|
579
582
|
<Box gap={1} width={3} flexWrap="wrap">
|
|
@@ -606,7 +609,7 @@ Size of the gap between an element's columns.
|
|
|
606
609
|
Type: `number`\
|
|
607
610
|
Default: `0`
|
|
608
611
|
|
|
609
|
-
Size of the gap between element's rows.
|
|
612
|
+
Size of the gap between an element's rows.
|
|
610
613
|
|
|
611
614
|
```jsx
|
|
612
615
|
<Box flexDirection="column" rowGap={1}>
|
|
@@ -897,7 +900,7 @@ Type: `string`\
|
|
|
897
900
|
Allowed values: `visible` `hidden`\
|
|
898
901
|
Default: `visible`
|
|
899
902
|
|
|
900
|
-
Behavior for an element's overflow in horizontal direction.
|
|
903
|
+
Behavior for an element's overflow in the horizontal direction.
|
|
901
904
|
|
|
902
905
|
##### overflowY
|
|
903
906
|
|
|
@@ -905,7 +908,7 @@ Type: `string`\
|
|
|
905
908
|
Allowed values: `visible` `hidden`\
|
|
906
909
|
Default: `visible`
|
|
907
910
|
|
|
908
|
-
Behavior for an element's overflow in vertical direction.
|
|
911
|
+
Behavior for an element's overflow in the vertical direction.
|
|
909
912
|
|
|
910
913
|
##### overflow
|
|
911
914
|
|
|
@@ -913,7 +916,7 @@ Type: `string`\
|
|
|
913
916
|
Allowed values: `visible` `hidden`\
|
|
914
917
|
Default: `visible`
|
|
915
918
|
|
|
916
|
-
|
|
919
|
+
A shortcut for setting `overflowX` and `overflowY` at the same time.
|
|
917
920
|
|
|
918
921
|
#### Borders
|
|
919
922
|
|
|
@@ -923,8 +926,8 @@ Type: `string`\
|
|
|
923
926
|
Allowed values: `single` `double` `round` `bold` `singleDouble` `doubleSingle` `classic` | `BoxStyle`
|
|
924
927
|
|
|
925
928
|
Add a border with a specified style.
|
|
926
|
-
If `borderStyle` is `undefined` (
|
|
927
|
-
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.
|
|
928
931
|
|
|
929
932
|
```jsx
|
|
930
933
|
<Box flexDirection="column">
|
|
@@ -990,7 +993,7 @@ See example in [examples/borders](examples/borders/borders.tsx).
|
|
|
990
993
|
Type: `string`
|
|
991
994
|
|
|
992
995
|
Change border color.
|
|
993
|
-
|
|
996
|
+
A shorthand for setting `borderTopColor`, `borderRightColor`, `borderBottomColor`, and `borderLeftColor`.
|
|
994
997
|
|
|
995
998
|
```jsx
|
|
996
999
|
<Box borderStyle="round" borderColor="green">
|
|
@@ -1026,19 +1029,6 @@ Accepts the same values as [`color`](#color) in `<Text>` component.
|
|
|
1026
1029
|
</Box>
|
|
1027
1030
|
```
|
|
1028
1031
|
|
|
1029
|
-
##### borderRightColor
|
|
1030
|
-
|
|
1031
|
-
Type: `string`
|
|
1032
|
-
|
|
1033
|
-
Change right border color.
|
|
1034
|
-
Accepts the same values as [`color`](#color) in `<Text>` component.
|
|
1035
|
-
|
|
1036
|
-
```jsx
|
|
1037
|
-
<Box borderStyle="round" borderRightColor="green">
|
|
1038
|
-
<Text>Hello world</Text>
|
|
1039
|
-
</Box>
|
|
1040
|
-
```
|
|
1041
|
-
|
|
1042
1032
|
##### borderBottomColor
|
|
1043
1033
|
|
|
1044
1034
|
Type: `string`
|
|
@@ -1071,7 +1061,7 @@ Type: `boolean`\
|
|
|
1071
1061
|
Default: `false`
|
|
1072
1062
|
|
|
1073
1063
|
Dim the border color.
|
|
1074
|
-
|
|
1064
|
+
A shorthand for setting `borderTopDimColor`, `borderBottomDimColor`, `borderLeftDimColor`, and `borderRightDimColor`.
|
|
1075
1065
|
|
|
1076
1066
|
```jsx
|
|
1077
1067
|
<Box borderStyle="round" borderDimColor>
|
|
@@ -1241,7 +1231,7 @@ World
|
|
|
1241
1231
|
### `<Spacer>`
|
|
1242
1232
|
|
|
1243
1233
|
A flexible space that expands along the major axis of its containing layout.
|
|
1244
|
-
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.
|
|
1245
1235
|
|
|
1246
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.
|
|
1247
1237
|
|
|
@@ -1259,8 +1249,8 @@ const Example = () => (
|
|
|
1259
1249
|
render(<Example />);
|
|
1260
1250
|
```
|
|
1261
1251
|
|
|
1262
|
-
In a vertical flex direction (`column`), it will position "Top"
|
|
1263
|
-
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.
|
|
1264
1254
|
|
|
1265
1255
|
```jsx
|
|
1266
1256
|
import {render, Box, Text, Spacer} from 'ink';
|
|
@@ -1280,14 +1270,14 @@ render(<Example />);
|
|
|
1280
1270
|
|
|
1281
1271
|
`<Static>` component permanently renders its output above everything else.
|
|
1282
1272
|
It's useful for displaying activity like completed tasks or logs - things that
|
|
1283
|
-
|
|
1273
|
+
don't change after they're rendered (hence the name "Static").
|
|
1284
1274
|
|
|
1285
|
-
It's preferred to use `<Static>` for use cases like these
|
|
1286
|
-
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.
|
|
1287
1277
|
|
|
1288
1278
|
For example, [Tap](https://github.com/tapjs/node-tap) uses `<Static>` to display
|
|
1289
1279
|
a list of completed tests. [Gatsby](https://github.com/gatsbyjs/gatsby) uses it
|
|
1290
|
-
to display a list of generated pages
|
|
1280
|
+
to display a list of generated pages while still displaying a live progress bar.
|
|
1291
1281
|
|
|
1292
1282
|
```jsx
|
|
1293
1283
|
import React, {useState, useEffect} from 'react';
|
|
@@ -1344,8 +1334,8 @@ const Example = () => {
|
|
|
1344
1334
|
render(<Example />);
|
|
1345
1335
|
```
|
|
1346
1336
|
|
|
1347
|
-
**Note:** `<Static>` only renders new items in `items` prop and ignores items
|
|
1348
|
-
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`
|
|
1349
1339
|
array, changes you make to previous items will not trigger a rerender.
|
|
1350
1340
|
|
|
1351
1341
|
See [examples/static](examples/static/static.tsx) for an example usage of `<Static>` component.
|
|
@@ -1354,7 +1344,7 @@ See [examples/static](examples/static/static.tsx) for an example usage of `<Stat
|
|
|
1354
1344
|
|
|
1355
1345
|
Type: `Array`
|
|
1356
1346
|
|
|
1357
|
-
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.
|
|
1358
1348
|
|
|
1359
1349
|
#### style
|
|
1360
1350
|
|
|
@@ -1373,11 +1363,11 @@ See [`<Box>`](#box) for supported properties.
|
|
|
1373
1363
|
|
|
1374
1364
|
Type: `Function`
|
|
1375
1365
|
|
|
1376
|
-
Function that is called to render every item in `items` array.
|
|
1377
|
-
|
|
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
|
|
1378
1368
|
`items` array.
|
|
1379
1369
|
|
|
1380
|
-
Note that `key` must be assigned to the root component.
|
|
1370
|
+
Note that a `key` must be assigned to the root component.
|
|
1381
1371
|
|
|
1382
1372
|
```jsx
|
|
1383
1373
|
<Static items={['a', 'b', 'c']}>
|
|
@@ -1396,12 +1386,12 @@ Note that `key` must be assigned to the root component.
|
|
|
1396
1386
|
|
|
1397
1387
|
### `<Transform>`
|
|
1398
1388
|
|
|
1399
|
-
Transform a string representation of React components before they
|
|
1400
|
-
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).
|
|
1401
|
-
These use cases can't accept React nodes as input
|
|
1402
|
-
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.
|
|
1403
1393
|
|
|
1404
|
-
**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.
|
|
1405
1395
|
|
|
1406
1396
|
```jsx
|
|
1407
1397
|
import {render, Transform} from 'ink';
|
|
@@ -1415,7 +1405,7 @@ const Example = () => (
|
|
|
1415
1405
|
render(<Example />);
|
|
1416
1406
|
```
|
|
1417
1407
|
|
|
1418
|
-
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".
|
|
1419
1409
|
|
|
1420
1410
|
When the output wraps to multiple lines, it can be helpful to know which line is being processed.
|
|
1421
1411
|
|
|
@@ -1455,8 +1445,8 @@ render(
|
|
|
1455
1445
|
|
|
1456
1446
|
Type: `Function`
|
|
1457
1447
|
|
|
1458
|
-
Function
|
|
1459
|
-
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.
|
|
1460
1450
|
|
|
1461
1451
|
##### children
|
|
1462
1452
|
|
|
@@ -1468,16 +1458,16 @@ Output of child components.
|
|
|
1468
1458
|
|
|
1469
1459
|
Type: `number`
|
|
1470
1460
|
|
|
1471
|
-
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.
|
|
1472
1462
|
|
|
1473
1463
|
## Hooks
|
|
1474
1464
|
|
|
1475
1465
|
### useInput(inputHandler, options?)
|
|
1476
1466
|
|
|
1477
1467
|
This hook is used for handling user input.
|
|
1478
|
-
It's a more convenient alternative to using `useStdin` and listening
|
|
1479
|
-
The callback you pass to `useInput` is called for each character when user enters any input.
|
|
1480
|
-
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`.
|
|
1481
1471
|
You can find a full example of using `useInput` at [examples/use-input](examples/use-input/use-input.tsx).
|
|
1482
1472
|
|
|
1483
1473
|
```jsx
|
|
@@ -1528,7 +1518,7 @@ Type: `boolean`\
|
|
|
1528
1518
|
Default: `false`
|
|
1529
1519
|
|
|
1530
1520
|
If an arrow key was pressed, the corresponding property will be `true`.
|
|
1531
|
-
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`.
|
|
1532
1522
|
|
|
1533
1523
|
###### key.return
|
|
1534
1524
|
|
|
@@ -1586,8 +1576,8 @@ Delete key was pressed.
|
|
|
1586
1576
|
Type: `boolean`\
|
|
1587
1577
|
Default: `false`
|
|
1588
1578
|
|
|
1589
|
-
If Page Up or Page Down key was pressed, the corresponding property will be `true`.
|
|
1590
|
-
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`.
|
|
1591
1581
|
|
|
1592
1582
|
###### key.meta
|
|
1593
1583
|
|
|
@@ -1610,7 +1600,7 @@ Useful when there are multiple `useInput` hooks used at once to avoid handling t
|
|
|
1610
1600
|
|
|
1611
1601
|
### useApp()
|
|
1612
1602
|
|
|
1613
|
-
`useApp` is a React hook
|
|
1603
|
+
`useApp` is a React hook that exposes a method to manually exit the app (unmount).
|
|
1614
1604
|
|
|
1615
1605
|
#### exit(error?)
|
|
1616
1606
|
|
|
@@ -1643,14 +1633,14 @@ const Example = () => {
|
|
|
1643
1633
|
|
|
1644
1634
|
### useStdin()
|
|
1645
1635
|
|
|
1646
|
-
`useStdin` is a React hook
|
|
1636
|
+
`useStdin` is a React hook that exposes the stdin stream.
|
|
1647
1637
|
|
|
1648
1638
|
#### stdin
|
|
1649
1639
|
|
|
1650
1640
|
Type: `stream.Readable`\
|
|
1651
1641
|
Default: `process.stdin`
|
|
1652
1642
|
|
|
1653
|
-
|
|
1643
|
+
The stdin stream passed to `render()` in `options.stdin`, or `process.stdin` by default.
|
|
1654
1644
|
Useful if your app needs to handle user input.
|
|
1655
1645
|
|
|
1656
1646
|
```js
|
|
@@ -1717,7 +1707,7 @@ const Example = () => {
|
|
|
1717
1707
|
|
|
1718
1708
|
### useStdout()
|
|
1719
1709
|
|
|
1720
|
-
`useStdout` is a React hook
|
|
1710
|
+
`useStdout` is a React hook that exposes the stdout stream where Ink renders your app.
|
|
1721
1711
|
|
|
1722
1712
|
#### stdout
|
|
1723
1713
|
|
|
@@ -1736,9 +1726,9 @@ const Example = () => {
|
|
|
1736
1726
|
|
|
1737
1727
|
#### write(data)
|
|
1738
1728
|
|
|
1739
|
-
Write any string to stdout
|
|
1740
|
-
It's useful when you want to display
|
|
1741
|
-
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.
|
|
1742
1732
|
|
|
1743
1733
|
##### data
|
|
1744
1734
|
|
|
@@ -1765,7 +1755,7 @@ See additional usage example in [examples/use-stdout](examples/use-stdout/use-st
|
|
|
1765
1755
|
|
|
1766
1756
|
### useStderr()
|
|
1767
1757
|
|
|
1768
|
-
`useStderr` is a React hook
|
|
1758
|
+
`useStderr` is a React hook that exposes the stderr stream.
|
|
1769
1759
|
|
|
1770
1760
|
#### stderr
|
|
1771
1761
|
|
|
@@ -1786,10 +1776,10 @@ const Example = () => {
|
|
|
1786
1776
|
|
|
1787
1777
|
#### write(data)
|
|
1788
1778
|
|
|
1789
|
-
Write any string to stderr
|
|
1779
|
+
Write any string to stderr while preserving Ink's output.
|
|
1790
1780
|
|
|
1791
|
-
It's useful when you want to display
|
|
1792
|
-
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.
|
|
1793
1783
|
|
|
1794
1784
|
##### data
|
|
1795
1785
|
|
|
@@ -1814,9 +1804,9 @@ const Example = () => {
|
|
|
1814
1804
|
|
|
1815
1805
|
### useFocus(options?)
|
|
1816
1806
|
|
|
1817
|
-
|
|
1818
|
-
If there are multiple components that execute `useFocus` hook, focus will be given to them in the order
|
|
1819
|
-
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.
|
|
1820
1810
|
|
|
1821
1811
|
#### options
|
|
1822
1812
|
|
|
@@ -1825,7 +1815,7 @@ This hook returns an object with `isFocused` boolean property, which determines
|
|
|
1825
1815
|
Type: `boolean`\
|
|
1826
1816
|
Default: `false`
|
|
1827
1817
|
|
|
1828
|
-
Auto
|
|
1818
|
+
Auto-focus this component if there's no active (focused) component right now.
|
|
1829
1819
|
|
|
1830
1820
|
##### isActive
|
|
1831
1821
|
|
|
@@ -1840,7 +1830,7 @@ This is useful for inputs that are temporarily disabled.
|
|
|
1840
1830
|
Type: `string`\
|
|
1841
1831
|
Required: `false`
|
|
1842
1832
|
|
|
1843
|
-
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.
|
|
1844
1834
|
|
|
1845
1835
|
```jsx
|
|
1846
1836
|
import {render, useFocus, Text} from 'ink';
|
|
@@ -1864,7 +1854,7 @@ This hook exposes methods to enable or disable focus management for all componen
|
|
|
1864
1854
|
|
|
1865
1855
|
Enable focus management for all components.
|
|
1866
1856
|
|
|
1867
|
-
**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.
|
|
1868
1858
|
|
|
1869
1859
|
```js
|
|
1870
1860
|
import {useFocusManager} from 'ink';
|
|
@@ -1883,7 +1873,7 @@ const Example = () => {
|
|
|
1883
1873
|
#### disableFocus()
|
|
1884
1874
|
|
|
1885
1875
|
Disable focus management for all components.
|
|
1886
|
-
|
|
1876
|
+
The currently active component (if there's one) will lose its focus.
|
|
1887
1877
|
|
|
1888
1878
|
```js
|
|
1889
1879
|
import {useFocusManager} from 'ink';
|
|
@@ -1903,7 +1893,7 @@ const Example = () => {
|
|
|
1903
1893
|
|
|
1904
1894
|
Switch focus to the next focusable component.
|
|
1905
1895
|
If there's no active component right now, focus will be given to the first focusable component.
|
|
1906
|
-
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.
|
|
1907
1897
|
|
|
1908
1898
|
**Note:** Ink calls this method when user presses <kbd>Tab</kbd>.
|
|
1909
1899
|
|
|
@@ -1925,7 +1915,7 @@ const Example = () => {
|
|
|
1925
1915
|
|
|
1926
1916
|
Switch focus to the previous focusable component.
|
|
1927
1917
|
If there's no active component right now, focus will be given to the first focusable component.
|
|
1928
|
-
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.
|
|
1929
1919
|
|
|
1930
1920
|
**Note:** Ink calls this method when user presses <kbd>Shift</kbd>+<kbd>Tab</kbd>.
|
|
1931
1921
|
|
|
@@ -1971,7 +1961,7 @@ const Example = () => {
|
|
|
1971
1961
|
|
|
1972
1962
|
### useIsScreenReaderEnabled()
|
|
1973
1963
|
|
|
1974
|
-
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.
|
|
1975
1965
|
|
|
1976
1966
|
```jsx
|
|
1977
1967
|
import {useIsScreenReaderEnabled, Text} from 'ink';
|
|
@@ -2024,26 +2014,36 @@ Input stream where app will listen for input.
|
|
|
2024
2014
|
Type: `boolean`\
|
|
2025
2015
|
Default: `true`
|
|
2026
2016
|
|
|
2027
|
-
Configure whether Ink should listen
|
|
2028
|
-
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.
|
|
2029
2019
|
|
|
2030
2020
|
###### patchConsole
|
|
2031
2021
|
|
|
2032
2022
|
Type: `boolean`\
|
|
2033
2023
|
Default: `true`
|
|
2034
2024
|
|
|
2035
|
-
Patch console methods to ensure console output doesn't mix with Ink output.
|
|
2036
|
-
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.
|
|
2037
|
-
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.
|
|
2038
2028
|
|
|
2039
|
-
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.
|
|
2040
2030
|
|
|
2041
2031
|
###### debug
|
|
2042
2032
|
|
|
2043
2033
|
Type: `boolean`\
|
|
2044
2034
|
Default: `false`
|
|
2045
2035
|
|
|
2046
|
-
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.
|
|
2047
2047
|
|
|
2048
2048
|
#### Instance
|
|
2049
2049
|
|
|
@@ -2051,7 +2051,7 @@ This is the object that `render()` returns.
|
|
|
2051
2051
|
|
|
2052
2052
|
##### rerender(tree)
|
|
2053
2053
|
|
|
2054
|
-
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.
|
|
2055
2055
|
|
|
2056
2056
|
###### tree
|
|
2057
2057
|
|
|
@@ -2078,7 +2078,7 @@ unmount();
|
|
|
2078
2078
|
|
|
2079
2079
|
##### waitUntilExit()
|
|
2080
2080
|
|
|
2081
|
-
Returns a promise
|
|
2081
|
+
Returns a promise that resolves when the app is unmounted.
|
|
2082
2082
|
|
|
2083
2083
|
```jsx
|
|
2084
2084
|
const {unmount, waitUntilExit} = render(<MyApp />);
|
|
@@ -2100,16 +2100,16 @@ clear();
|
|
|
2100
2100
|
#### measureElement(ref)
|
|
2101
2101
|
|
|
2102
2102
|
Measure the dimensions of a particular `<Box>` element.
|
|
2103
|
-
|
|
2104
|
-
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.
|
|
2105
2105
|
|
|
2106
|
-
**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.
|
|
2107
2107
|
|
|
2108
2108
|
##### ref
|
|
2109
2109
|
|
|
2110
2110
|
Type: `MutableRef`
|
|
2111
2111
|
|
|
2112
|
-
A reference to a `<Box>` element captured with
|
|
2112
|
+
A reference to a `<Box>` element captured with the `ref` property.
|
|
2113
2113
|
See [Refs](https://reactjs.org/docs/refs-and-the-dom.html) for more information on how to capture references.
|
|
2114
2114
|
|
|
2115
2115
|
```jsx
|
|
@@ -2157,7 +2157,7 @@ Check out [ink-testing-library](https://github.com/vadimdemedes/ink-testing-libr
|
|
|
2157
2157
|
|
|
2158
2158
|

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