Skip to main content
OpenTUI Solid is a custom SolidJS reconciler that brings fine-grained reactivity to terminal user interfaces. Build performant CLI apps with Solid’s reactive primitives.

Installation

Setup

1. Configure TypeScript

Add JSX configuration to your tsconfig.json:
tsconfig.json

2. Add Preload Script

Configure bunfig.toml to preload the Solid plugin:
bunfig.toml

3. Create Your App

index.tsx

4. Run Your App

Building for Production

Use Bun.build with the Solid plugin:
build.ts

Rendering

render

Render a Solid component tree into a CLI renderer:
Parameters:
  • node - Function returning a JSX element
  • rendererOrConfig? - CliRenderer instance or CliRendererConfig

testRender

Create a test renderer for snapshots and interaction tests:

Reactive Hooks

useRenderer

Access the OpenTUI renderer instance:

useKeyboard

Handle keyboard input with press and release events:
Parameters:
  • callback - Function receiving a KeyEvent object
  • options? - Optional configuration:
    • release?: boolean - Include key release events (default: false)
By default, only press events are received (including repeats with repeated: true). Set options.release = true to also receive release events.

onResize

Handle terminal resize events:

useTerminalDimensions

Get current terminal dimensions with automatic updates:
Returns: Signal containing { width: number, height: number }

usePaste

Handle paste events from the terminal:

useSelectionHandler

Handle text selection events:

useTimeline

Create and manage animations using OpenTUI’s timeline system:
Parameters:
  • options? - Optional TimelineOptions:
    • duration?: number - Animation duration in ms (default: 1000)
    • loop?: boolean - Whether to loop (default: false)
    • autoplay?: boolean - Auto-start timeline (default: true)
    • onComplete?: () => void - Completion callback
    • onPause?: () => void - Pause callback
Returns: Timeline instance with methods:
  • add(target, properties, startTime) - Add animation
  • play() - Start timeline
  • pause() - Pause timeline
  • restart() - Restart from beginning

Components

OpenTUI Solid provides intrinsic JSX elements that map to OpenTUI renderables:

Layout & Display

  • <text> - Display styled text
  • <box> - Container with borders and layout
  • <scrollbox> - Scrollable container
  • <ascii_font> - ASCII art text renderer
Notice the underscore in ascii_font - Solid uses underscores for multi-word element names.

Input Components

  • <input> - Single-line text input
  • <textarea> - Multi-line text input
  • <select> - Dropdown selection
  • <tab_select> - Tab-based selection

Code & Diff

  • <code> - Syntax-highlighted code blocks
  • <line_number> - Line-numbered code with diff/diagnostics
  • <diff> - Unified or split diff viewer

Text Modifiers

These elements must be used inside a <text> component:
  • <span> - Inline styled text
  • <strong>, <b> - Bold text
  • <em>, <i> - Italic text
  • <u> - Underlined text
  • <br> - Line break
  • <a> - Link with href attribute
See the Components section for detailed documentation on each component.

Advanced Components

Portal

Render children into a different mount point, useful for overlays and modals:

Dynamic

Render arbitrary intrinsic elements or components dynamically:

Examples

Counter with Reactive Updates

Interactive Todo List

Animated Progress Bar

Extending Components

Register custom renderables as JSX intrinsic elements:

Utilities

getComponentCatalogue

Get the current component catalogue that powers JSX tag lookup:

Performance Tips

Solid’s reactivity system updates only what changes. Avoid wrapping large component trees in effects - let Solid track dependencies automatically.
Destructuring props at the component level breaks reactivity. Access props directly or destructure in JSX.
When rendering lists where items don’t change identity, use <Index> instead of <For> for better performance.