SolidJS renderer for OpenTUI
npm install @opentui/solidSolid.js support for OpenTUI.
``bash`
bun install solid-js @opentui/solid
1. Add jsx config to tsconfig.json:
`json`
{
"compilerOptions": {
"jsx": "preserve",
"jsxImportSource": "@opentui/solid"
}
}
2. Add preload script to bunfig.toml:
`toml`
preload = ["@opentui/solid/preload"]
3. Add render function to index.tsx:
`tsx
import { render } from "@opentui/solid"
render(() =>
`
4. Run with bun index.tsx.
5. To build use Bun.build (source):
`ts
import solidPlugin from "@opentui/solid/bun-plugin"
await Bun.build({
entrypoints: ["./index.tsx"],
target: "bun",
outdir: "./build",
plugins: [solidPlugin],
compile: {
target: "bun-darwin-arm64",
outfile: "app-macos",
},
})
`
- Core Concepts
- Components
- API Reference
- render(node, rendererOrConfig?)
- testRender(node, options?)
- extend(components)
- getComponentCatalogue()
- Hooks
- Portal
- Dynamic
- Components
- Layout & Display
- Input
- Code & Diff
- Text Modifiers
OpenTUI Solid exposes intrinsic JSX elements that map to OpenTUI renderables:
- Layout & Display: text, box, scrollbox, ascii_fontinput
- Input: , textarea, select, tab_selectcode
- Code & Diff: , line_number, diffspan
- Text Modifiers: , strong, b, em, i, u, br, a
Render a Solid component tree into a CLI renderer. If rendererOrConfig is omitted, a renderer is created with default options.
`tsx
import { render } from "@opentui/solid"
render(() =>
`
Parameters:
- node: Function returning a JSX element.rendererOrConfig?
- : CliRenderer instance or CliRendererConfig.
Create a test renderer for snapshots and interaction tests.
`tsx
import { testRender } from "@opentui/solid"
const testSetup = await testRender(() =>
`
Register custom renderables as JSX intrinsic elements.
`tsx
import { extend } from "@opentui/solid"
extend({ customBox: CustomBoxRenderable })
`
Returns the current component catalogue that powers JSX tag lookup.
- useRenderer()onResize(callback)
- useTerminalDimensions()
- useKeyboard(handler, options?)
- usePaste(handler)
- useSelectionHandler(handler)
- useTimeline(options?)
-
Render children into a different mount node, useful for overlays and tooltips.
`tsx`
import { Portal } from "@opentui/solid"
;
Render arbitrary intrinsic elements or components dynamically.
`tsx`
import { Dynamic } from "@opentui/solid"
;
- text: styled text containerbox
- : layout container with borders, padding, and flex settingsscrollbox
- : scrollable containerascii_font
- : ASCII art text renderer
- input: single-line text inputtextarea
- : multi-line text inputselect
- : list selectiontab_select
- : tab-based selection
- code: syntax-highlighted code blocksline_number
- : line-numbered code display with diff/diagnostic helpersdiff
- : unified or split diff viewer
These must appear inside a text component:
- span: inline styled textstrong
- /b: bold textem
- /i: italic textu
- : underline textbr
- : line breaka
- : link text with href`