Skip to content

Transform ​

Applies a string transformation to each line of rendered text output. Compatible with Ink's Transform component.

Import ​

tsx
import { Transform } from "silvery"

Props ​

PropTypeDefaultDescription
transform(line: string, index: number) => stringrequiredFunction that transforms each line of output
childrenReactNode--Text content to transform

Usage ​

tsx
// Uppercase all text
<Transform transform={output => output.toUpperCase()}>
  <Text>Hello World</Text>
</Transform>

// Add line numbers
<Transform transform={(line, index) => `${index + 1}: ${line}`}>
  <Text>First line{'\n'}Second line</Text>
</Transform>

Notes ​

Transform must be applied only to Text children and should not change the dimensions of the output -- otherwise layout will be incorrect.

See Also ​

  • Text -- text rendering primitive