Skip to content

Components

inkx provides the same components as Ink, with some enhancements.

Box

The primary layout component. Uses Yoga (flexbox) for layout.

tsx
import { Box, Text } from "inkx"
;<Box flexDirection="row" justifyContent="space-between">
  <Text>Left</Text>
  <Text>Right</Text>
</Box>

New in inkx: Scrolling

Use overflow="scroll" with scrollTo for automatic scrolling:

tsx
<Box flexDirection="column" overflow="scroll" scrollTo={selectedIndex}>
  {items.map((item, i) => (
    <Text key={i} inverse={i === selectedIndex}>
      {item}
    </Text>
  ))}
</Box>

See Scrolling Guide for details.

Props

PropTypeDefaultDescription
flexDirection"row" | "column" | "row-reverse" | "column-reverse""row"Main axis direction
flexGrownumber0Grow factor
flexShrinknumber1Shrink factor
flexBasisnumber | string-Initial size
justifyContent"flex-start" | "flex-end" | "center" | "space-between" | "space-around""flex-start"Main axis alignment
alignItems"flex-start" | "flex-end" | "center" | "stretch""stretch"Cross axis alignment
paddingnumber0Padding on all sides
paddingXnumber0Horizontal padding
paddingYnumber0Vertical padding
marginnumber0Margin on all sides
widthnumber | string-Fixed or percentage width
heightnumber | string-Fixed or percentage height
minWidthnumber-Minimum width
minHeightnumber-Minimum height
borderStyle"single" | "double" | "round" | "bold" | "classic"-Border style
borderColorstring-Border color
overflow"visible" | "hidden" | "scroll""visible"inkx only: Overflow behavior
scrollTonumber-inkx only: Child index to keep visible

Text

Renders text with styling. Supports Chalk strings.

tsx
import { Text } from "inkx";
import chalk from "chalk";

// Basic styling
<Text color="green" bold>Success!</Text>

// Chalk strings work too
<Text>{chalk.red.bold("Error!")}</Text>

New in inkx: Auto-Truncation

Text automatically truncates to fit available width:

tsx
<Box width={20}>
  <Text>This is a very long text that will be truncated</Text>
</Box>
// Output: "This is a very lon…"

Opt out with wrap={false} if you need overflow behavior.

Props

PropTypeDefaultDescription
colorstring-Text color
backgroundColorstring-Background color
boldbooleanfalseBold text
italicbooleanfalseItalic text
underlinebooleanfalseUnderlined text
strikethroughbooleanfalseStrikethrough text
dimColorbooleanfalseDimmed color
inversebooleanfalseSwap foreground/background
wrap"wrap" | "truncate" | "truncate-start" | "truncate-middle" | "truncate-end""truncate"Text wrapping behavior

Newline

Renders a newline character.

tsx
import { Newline, Text } from "inkx";

<Text>Line 1</Text>
<Newline />
<Text>Line 2</Text>

Spacer

Flexible space that expands to fill available room.

tsx
import { Box, Spacer, Text } from "inkx"
;<Box>
  <Text>Left</Text>
  <Spacer />
  <Text>Right</Text>
</Box>

Static

Renders content that won't be updated. Useful for logs or output that scrolls up.

tsx
import { Static, Box, Text } from "inkx"

function App() {
  const [logs, setLogs] = useState<string[]>([])

  return (
    <Box flexDirection="column">
      <Static items={logs}>{(log, i) => <Text key={i}>{log}</Text>}</Static>
      <Text>Current status...</Text>
    </Box>
  )
}

Props

PropTypeDescription
itemsT[]Array of items to render
children(item: T, index: number) => ReactNodeRender function

Released under the MIT License.