@androidtui/solid

中文文档
0.8.3发布于 2026/11/09MITTypeScriptESM + CJS近 30 天下载 1713

SolidJS renderer for OpenTUI terminal applications on Android and Termux

原始使用文档
文档目录18 节
  1. Installation
  2. Usage
  3. Table of Contents
  4. Core Concepts
  5. Components
  6. API Reference
  7. render(node, rendererOrConfig?)
  8. testRender(node, options?)
  9. extend(components)
  10. getComponentCatalogue()
  11. Hooks
  12. Portal
  13. Dynamic
  14. Components
  15. Layout & Display
  16. Input
  17. Code & Diff
  18. Text Modifiers

@opentui/solid

Solid.js support for OpenTUI.

Installation

bun install solid-js@^1.9 @opentui/solid

Usage

  1. Add jsx config to tsconfig.json:
{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "@opentui/solid"
  }
}
  1. Add preload script to bunfig.toml:
preload = ["@opentui/solid/preload"]
  1. Add render function to index.tsx:
import { render } from "@opentui/solid"

render(() => <text>Hello, World!</text>)
  1. Run with bun index.tsx.

  2. To build use Bun.build (source):

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",
  },
})

Table of Contents

Core Concepts

Components

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

  • Layout & Display: text, box, scrollbox, ascii_font
  • Input: input, textarea, select, tab_select
  • Code & Diff: code, line_number, diff
  • Text Modifiers: span, strong, b, em, i, u, br, a

API Reference

render(node, rendererOrConfig?)

Render a Solid component tree into a CLI renderer. If you omit rendererOrConfig, render() creates a renderer with default options. render() returns a promise that resolves after the initial mount. Destroying the renderer disposes the Solid root.

import { render } from "@opentui/solid"

render(() => <App />)

Parameters:

  • node: Function returning a JSX element.
  • rendererOrConfig?: CliRenderer instance or CliRendererConfig.

testRender(node, options?)

Create a test renderer for snapshots and interaction tests.

import { testRender } from "@opentui/solid"

const testSetup = await testRender(() => <App />, { width: 40, height: 10 })

extend(components)

Register custom renderables as JSX intrinsic elements.

import { extend } from "@opentui/solid"

extend({ customBox: CustomBoxRenderable })

Solid calls the constructor with { id } only. After construction, Solid applies each JSX prop to the instance. A class that reads a value only from its constructor options does not get that value from JSX.

getComponentCatalogue()

Returns the current component catalogue that powers JSX tag lookup.

Hooks

  • useRenderer()
  • onResize(callback)
  • onFocus(callback)
  • onBlur(callback)
  • useTerminalDimensions()
  • useKeyboard(handler, options?)
  • usePaste(handler)
  • useSelectionHandler(handler)
  • useTimeline(options?)

Portal

Render children into a different mount node. Use it for overlays and tooltips.

import { Portal } from "@opentui/solid"
;<Portal mount={renderer.root}>
  <box border>Overlay</box>
</Portal>

Dynamic

Render arbitrary intrinsic elements or components dynamically.

import { Dynamic } from "@opentui/solid"
;<Dynamic component={isMultiline() ? "textarea" : "input"} />

Components

Layout & Display

  • text: styled text container
  • box: layout container with borders, padding, and flex settings
  • scrollbox: scrollable container
  • ascii_font: ASCII art text renderer

For QR codes, call registerQRCode() from @opentui/qrcode/solid. It registers the qr_code element.

Input

  • input: single-line text input
  • textarea: multi-line text input
  • select: list selection
  • tab_select: tab-based selection

Code & Diff

  • code: syntax-highlighted code blocks
  • line_number: line-numbered code display with diff/diagnostic helpers
  • diff: unified or split diff viewer

Text Modifiers

Use these only inside a text component:

  • span: inline styled text
  • strong/b: bold text
  • em/i: italic text
  • u: underline text
  • br: line break
  • a: link text with href

版本与发布记录

@androidtui/solid 共发布 30 个版本,首次发布于 2026/08/09;过去 12 个月发布了 30 个版本。

版本发布日期距今
0.8.3latest2026/11/09今天
0.8.02026/10/3010 天前
0.7.02026/10/3010 天前
0.6.82026/10/2416 天前
0.6.62026/10/1526 天前
0.6.52026/10/1426 天前

其他发布通道:future → 0.5.12-android.1。

关于 @androidtui/solid 的常见问题

@androidtui/solid 是什么?

SolidJS renderer for OpenTUI terminal applications on Android and Termux

如何安装 @androidtui/solid?

在项目目录运行 npm install @androidtui/solid,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:solid-js(^1.9.12)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@androidtui/solid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@androidtui/solid 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@androidtui/solid 可以商用吗?

@androidtui/solid 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@androidtui/solid 的下载量有多少?

根据 npm 官方下载统计,@androidtui/solid 在 2026/10/06 – 2026/11/04 这 30 天内被下载 1,713 次,日均约 57 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@androidtui/solid 还在维护吗?

最新版本 0.8.3 发布于 2026/11/09(今天);至今共发布 30 个版本,其中过去 12 个月发布了 30 个;首次发布于 2026/08/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。