shadcn-labs/termcn / .agents/skills/ink
ink
VerifiedComprehensive Ink skill for building CLI applications with React. Covers components (Text, Box, Static, Transform), hooks (useInput, useApp, useFocus), Flexbox layout, testing, and accessibility.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.2 KB |
| references/accessibility/REFERENCE.md | markdown | 5.3 KB |
| references/components/REFERENCE.md | markdown | 1.7 KB |
| references/components/box.md | markdown | 4.9 KB |
| references/components/text.md | markdown | 2.4 KB |
| references/components/utilities.md | markdown | 3.3 KB |
| references/core/REFERENCE.md | markdown | 3.1 KB |
| references/core/api.md | markdown | 3.4 KB |
| references/core/configuration.md | markdown | 3.7 KB |
| references/core/gotchas.md | markdown | 4.6 KB |
| references/core/patterns.md | markdown | 6.7 KB |
| references/hooks/REFERENCE.md | markdown | 1.7 KB |
| references/hooks/app-lifecycle.md | markdown | 1.9 KB |
| references/hooks/focus.md | markdown | 5.2 KB |
| references/hooks/input.md | markdown | 3.7 KB |
| references/hooks/stdio.md | markdown | 3.1 KB |
| references/layout/REFERENCE.md | markdown | 4.1 KB |
| references/layout/patterns.md | markdown | 3.8 KB |
| references/testing/REFERENCE.md | markdown | 5.3 KB |
| rules/RULES.md | markdown | 1.4 KB |
| rules/components.md | markdown | 8.3 KB |
| rules/core.md | markdown | 9.0 KB |
| rules/hooks.md | markdown | 10.1 KB |
| rules/performance.md | markdown | 6.6 KB |
references/core/api.md
View on GitHub# Core API Reference
## render(tree, options?)
Mount a component and render the output. Returns an `Instance`.
```jsx
import {render} from 'ink';
const instance = render(<MyApp />);
```
### Options
```jsx
render(<MyApp />, {
stdout: process.stdout, // Output stream (default: process.stdout)
stdin: process.stdin, // Input stream (default: process.stdin)
stderr: process.stderr, // Error stream (default: process.stderr)
exitOnCtrlC: true, // Exit on Ctrl+C (default: true)
patchConsole: true, // Patch console.* methods (default: true)
debug: false, // Render each update separately (default: false)
maxFps: 30, // Max frames per second (default: 30)
incrementalRendering: false, // Only update changed lines (default: false)
concurrent: false, // React Concurrent mode (default: false)
isScreenReaderEnabled: false, // Screen reader support (default: env check)
onRender: ({renderTime}) => {},// Callback after each render
kittyKeyboard: undefined, // Kitty keyboard protocol options
});
```
### Instance
The object returned by `render()`:
```jsx
const {rerender, unmount, waitUntilExit, cleanup, clear} = render(<MyApp />);
```
#### rerender(tree)
Replace or update the root node:
```jsx
const {rerender} = render(<Counter count={1} />);
rerender(<Counter count={2} />);
```
#### unmount()
Manually unmount the whole app:
```jsx
const {unmount} = render(<MyApp />);
unmount();
```
#### waitUntilExit()
Returns a promise that settles when the app unmounts:
```jsx
const {waitUntilExit} = render(<MyApp />);
await waitUntilExit(); // resolves after unmount
```
It resolves with the value passed to `exit(value)` and rejects with the error passed to `exit(error)`.
#### cleanup()
Delete the internal Ink instance for the current stdout. Useful in tests where you need `render()` to create a fresh instance.
#### clear()
Clear rendered output:
```jsx
const {clear} = render(<MyApp />);
clear();
```
## renderToString(tree, options?)
Render a React element to a string synchronously. Does not write to stdout, does not set up terminal listeners.
```jsx
import {renderToString, Text, Box} from 'ink';
const output = renderToString(
<Box padding={1}>
<Text color="green">Hello World</Text>
</Box>,
);
console.log(output);
```
### Options
```jsx
renderToString(<MyApp />, {
columns: 80, // Virtual terminal width (default: 80)
});
```
**Notes:**
- Terminal hooks (`useInput`, `useStdin`, `useApp`, etc.) return default no-op values
- `useEffect` callbacks execute but state updates don't affect the returned output
- `useLayoutEffect` callbacks fire synchronously and **will** affect the output
- `<Static>` is supported — its output is prepended
## measureElement(ref)
Measure the dimensions of a `<Box>` element. Returns `{width, height}`.
**Important:** Returns `{width: 0, height: 0}` during render. Call from `useEffect`, `useLayoutEffect`, input handlers, or timer callbacks.
```jsx
import {useRef, useEffect} from 'react';
import {render, measureElement, Box, Text} from 'ink';
const Example = () => {
const ref = useRef();
useEffect(() => {
const {width, height} = measureElement(ref.current);
// width = 100, height = 1
}, []);
return (
<Box width={100}>
<Box ref={ref}>
<Text>This box will stretch to 100 width</Text>
</Box>
</Box>
);
};
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |