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/hooks/stdio.md
View on GitHub# useStdin, useStdout, useStderr
Access stdio streams and terminal dimensions from within components.
## useStdin
Access the stdin stream and check raw mode state.
### Import
```jsx
import {useStdin} from 'ink';
```
### Usage
```jsx
const {stdin, isRawModeSupported, setRawMode} = useStdin();
```
### Returns
| Property | Type | Description |
|----------|------|-------------|
| `stdin` | `ReadableStream` | The stdin stream |
| `isRawModeSupported` | `boolean` | Whether raw mode is available |
| `setRawMode` | `(mode: boolean) => void` | Enable/disable raw mode |
### Raw Mode
Raw mode sends individual keypresses to your app instead of line-buffered input. `useInput` enables raw mode automatically.
```jsx
const {setRawMode, isRawModeSupported} = useStdin();
if (isRawModeSupported) {
setRawMode(true); // Enable raw mode
}
```
**Note:** `setRawMode` is reference-counted. Each call to `setRawMode(true)` increments a counter; `setRawMode(false)` decrements it. Raw mode stays on until all callers release it.
### Reading Raw Data
```jsx
const {stdin} = useStdin();
useEffect(() => {
const onData = (data) => {
console.log('stdin:', data.toString());
};
stdin.on('data', onData);
return () => stdin.off('data', onData);
}, []);
```
---
## useStdout
Access the stdout stream and terminal dimensions.
### Import
```jsx
import {useStdout} from 'ink';
```
### Usage
```jsx
const {stdout, write} = useStdout();
```
### Returns
| Property | Type | Description |
|----------|------|-------------|
| `stdout` | `WritableStream` | The stdout stream |
| `write` | `(data: string) => void` | Write directly to stdout |
### Terminal Dimensions
```jsx
const {stdout} = useStdout();
const columns = stdout.columns; // Terminal width
const rows = stdout.rows; // Terminal height
```
### Direct Write
Write output outside Ink's rendering:
```jsx
const {write} = useStdout();
write('This bypasses Ink rendering\n');
```
**Warning:** Direct writes mix with Ink output. Use sparingly.
---
## useStderr
Access the stderr stream for error output.
### Import
```jsx
import {useStderr} from 'ink';
```
### Usage
```jsx
const {stderr, write} = useStderr();
```
### Returns
| Property | Type | Description |
|----------|------|-------------|
| `stderr` | `WritableStream` | The stderr stream |
| `write` | `(data: string) => void` | Write directly to stderr |
### Stderr Dimensions
```jsx
const {stderr} = useStderr();
const columns = stderr.columns;
const rows = stderr.rows;
```
## Patterns
### Responsive to Terminal Size
```jsx
const {stdout} = useStdout();
const isWide = stdout.columns > 80;
return (
<Box flexDirection={isWide ? 'row' : 'column'}>
<Box width={isWide ? '30%' : '100%'}>
<Text>Sidebar</Text>
</Box>
<Box flexGrow={1}>
<Text>Content</Text>
</Box>
</Box>
);
```
### Logging to Stderr
Write logs/debug info to stderr so they don't mix with stdout:
```jsx
const {write} = useStderr();
write(`[DEBUG] Processing item ${id}\n`);
```
## See Also
- [Input](./input.md) - useInput for keyboard handling
- [Configuration](../core/configuration.md) - stdin/stdout/stderr options
- [Patterns](../core/patterns.md) - Responsive layout pattern
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 |