@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)render(component: Component)- Render a componentshowOverlay(component: Component, options?: OverlayOptions)- Show an overlayhideOverlay(handle: OverlayHandle)- Hide an overlayfocus(component: Component)- Focus a componentaddInputListener(listener: (data: string) => { consume?: boolean })- Add input listenerclose()- Clean up and restore terminal
Container
Container for multiple components with vertical layout.addChild(component: Component)- Add a child componentremoveChild(component: Component)- Remove a child componentclear()- Remove all children
Box
Box container with borders and padding.BoxOptions
Text
Simple text component.setText(text: string)- Update text contentgetText()- Get current text
TruncatedText
Text with automatic truncation.TruncatedTextOptions
Spacer
Vertical spacing component.Input Components
Editor
Multi-line text editor with syntax highlighting.EditorOptions
setText(text: string)- Set editor contentgetText()- Get editor contentclear()- Clear editorfocus()- Focus the editoron(event: string, handler: Function)- Subscribe to events
submit- User pressed Enter/Ctrl+Entercancel- User pressed Escapechange- Text changed
SelectList
Selectable list with keyboard navigation.SelectListOptions
setItems(items: SelectItem[])- Update itemsgetSelectedItem()- Get selected itemon(event: string, handler: Function)- Subscribe to events
select- Item selectedcancel- User pressed Escape
SettingsList
Settings list with keyboard navigation.Input
Single-line text input.Display Components
Markdown
Markdown renderer with syntax highlighting.MarkdownOptions
setContent(markdown: string)- Update content
Image
Image display with iTerm2/Kitty protocol support.ImageOptions
required