Skip to main content
The @mariozechner/pi-tui package provides components for building terminal user interfaces.

Import

Core Components

TUI

The main TUI manager that handles rendering and input.
Terminal
required
Terminal interface (use ProcessTerminal for stdio)
Methods:
  • render(component: Component) - Render a component
  • showOverlay(component: Component, options?: OverlayOptions) - Show an overlay
  • hideOverlay(handle: OverlayHandle) - Hide an overlay
  • focus(component: Component) - Focus a component
  • addInputListener(listener: (data: string) => { consume?: boolean }) - Add input listener
  • close() - Clean up and restore terminal

Container

Container for multiple components with vertical layout.
Methods:
  • addChild(component: Component) - Add a child component
  • removeChild(component: Component) - Remove a child component
  • clear() - Remove all children

Box

Box container with borders and padding.
BoxOptions

Text

Simple text component.
Methods:
  • setText(text: string) - Update text content
  • getText() - Get current text

TruncatedText

Text with automatic truncation.
TruncatedTextOptions

Spacer

Vertical spacing component.

Input Components

Editor

Multi-line text editor with syntax highlighting.
EditorOptions
Methods:
  • setText(text: string) - Set editor content
  • getText() - Get editor content
  • clear() - Clear editor
  • focus() - Focus the editor
  • on(event: string, handler: Function) - Subscribe to events
Events:
  • submit - User pressed Enter/Ctrl+Enter
  • cancel - User pressed Escape
  • change - Text changed

SelectList

Selectable list with keyboard navigation.
SelectListOptions
Methods:
  • setItems(items: SelectItem[]) - Update items
  • getSelectedItem() - Get selected item
  • on(event: string, handler: Function) - Subscribe to events
Events:
  • select - Item selected
  • cancel - User pressed Escape

SettingsList

Settings list with keyboard navigation.

Input

Single-line text input.

Display Components

Markdown

Markdown renderer with syntax highlighting.
MarkdownOptions
Methods:
  • setContent(markdown: string) - Update content

Image

Image display with iTerm2/Kitty protocol support.
ImageOptions
required

Loader

Spinner animation.

CancellableLoader

Loader with cancel button.

Example: Complete UI