Installation
Setup
1. Configure TypeScript
Add JSX configuration to yourtsconfig.json:
tsconfig.json
2. Add Preload Script
Configurebunfig.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:node- Function returning a JSX elementrendererOrConfig?-CliRendererinstance orCliRendererConfig
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:callback- Function receiving aKeyEventobjectoptions?- 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:{ 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:options?- OptionalTimelineOptions: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 callbackonPause?: () => void- Pause callback
Timeline instance with methods:
add(target, properties, startTime)- Add animationplay()- Start timelinepause()- Pause timelinerestart()- 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
<span>- Inline styled text<strong>,<b>- Bold text<em>,<i>- Italic text<u>- Underlined text<br>- Line break<a>- Link withhrefattribute
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
Use fine-grained reactivity
Use fine-grained reactivity
Solid’s reactivity system updates only what changes. Avoid wrapping large component trees in effects - let Solid track dependencies automatically.
Destructure props in render, not component body
Destructure props in render, not component body
Destructuring props at the component level breaks reactivity. Access props directly or destructure in JSX.
Use Index for static lists
Use Index for static lists
When rendering lists where items don’t change identity, use
<Index> instead of <For> for better performance.