Terminal UI Overview
Bunli provides first-class support for building interactive terminal user interfaces using React and OpenTUI. The TUI system is split across two complementary packages:@bunli/runtime- Core rendering runtime, prompt primitives, and lifecycle management@bunli/tui- React components, hooks, and UI primitives
Quick Start
Architecture
Component Hierarchy
OpenTUI Integration
Bunli uses OpenTUI as its terminal rendering engine. OpenTUI provides:- React Renderer - Render React components to the terminal
- Layout Engine - Flexbox-like layout for terminal UIs
- Event System - Keyboard and resize events
- Primitive Components -
<box>,<text>,<input>,<select>, etc.
When to Use TUI vs Plain Console
Use TUI When:
✅ Building interactive workflows that require user input✅ Need real-time updates and animations
✅ Want structured layouts with borders and styling
✅ Building forms with validation and field navigation
✅ Creating dashboard views with live data
✅ Need keyboard navigation (menus, tables, command palettes)
Use Plain Console When:
✅ Simple log-based output is sufficient✅ Running in CI/CD pipelines (non-interactive)
✅ Scripting and automation contexts
✅ Need parseable output for other tools
✅ Minimal terminal compatibility requirements
Buffer Modes
Bunli supports two terminal buffer modes:Standard Buffer (Default)
- Renders in the scrollback buffer
- Output persists after command exits
- Best for CLI-style interactions (prompts, progress)
- Mouse tracking disabled by default to prevent escape sequences
Alternate Buffer
- Full-screen mode using alternate screen buffer
- Screen clears when command exits
- Best for fullscreen apps (editors, dashboards)
- Can enable mouse tracking safely
Render Lifecycle
Commands withrender must eventually call renderer.destroy() to exit:
renderer.destroy(), the command will hang.
Non-Interactive Fallback
Always provide ahandler fallback for non-interactive environments:
Module Organization
Bunli TUI provides subpath exports for different use cases:Next Steps
Prompts
Learn about input prompts, selections, and spinners
Rendering
Understand the renderer API and React integration
Components
Explore available UI components
Interactive UIs
Build full interactive interfaces