← 返回 Skills 市场
openlark

OpenTUI — Native Terminal UI Framework

作者 OpenLark · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
15
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install opentui
功能描述
OpenTUI — Zig-native terminal UI framework. Covers installation, renderer, components (Text/Box/Input/Select/Code/ScrollBox), Constructs declarative API, Fle...
使用说明 (SKILL.md)

OpenTUI — Native Terminal UI Framework

Zig-native TUI core with TypeScript bindings and Yoga Flexbox layout. Powers OpenCode in production.

Use Cases

Use when building terminal TUI applications.

Installation

bun init -y && bun add @opentui/core
# React: bun add @opentui/react @opentui/core react; bun create tui --template react
# Solid: bun add solid-js @opentui/solid

Renderer

const r = await createCliRenderer({
  screenMode: "alternate-screen"|"main-screen"|"split-footer",
  targetFps: 30, exitOnCtrlC: true, useMouse: true, autoFocus: true,
  backgroundColor: "transparent", consoleMode: "console-overlay"|"disabled",
})
r.root.add(Text({ content:"Hello", fg:"#0F0" }))
r.start()/stop()/pause()/suspend()/resume()/destroy()
r.on("resize",(w,h)=>{}); r.on("focus"|"blur"|"destroy",()=>{})
r.on("theme_mode",m=>{}); r.on("selection",s=>s.getSelectedText())
r.setTerminalTitle("t"); r.setBackgroundColor("#0D1117")

// Scrollback (split-footer mode)
r.writeToScrollback(ctx=>({root,width:ctx.width,height:1,startOnNewLine:true}))
const sf = r.createScrollbackSurface({}); sf.root.add(code); sf.settle(); sf.destroy()

Components

// Text
Text({content:"hello",fg:"#F00",bg:"#222",attributes:BOLD|UNDERLINE,selectable:true,position:"absolute",left:10,top:5})
// Attributes: BOLD DIM ITALIC UNDERLINE BLINK INVERSE HIDDEN STRIKETHROUGH
// Inline template: t`${bold("t")}: ${fg("#F00")(italic("w"))} normal`

// Box
Box({width:30,height:10,borderStyle:"rounded"|"single"|"double"|"heavy",borderColor:"#FFF",
     title:"Settings",titleAlignment:"left"|"center"|"right",padding:1,gap:1,
     onMouseDown:()=>{},onMouseOver:()=>{},onMouseOut:()=>{}})

// Input
Input({width:25,placeholder:"Type...",backgroundColor:"#222",focusedBackgroundColor:"#333",
       textColor:"#FFF",cursorColor:"#0F0"})
input.focus(); input.value="new"; // Events: INPUT / CHANGE / ENTER

// Select
Select({width:30,height:8,options:[{name:"Option",description:"desc",value:any}],
        selectedIndex:0,backgroundColor:"#1a1a1a",selectedBackgroundColor:"#333366"})
// Arrow keys/jk navigate, Enter to select; Events: ITEM_SELECTED / SELECTION_CHANGED

// Code (Tree-sitter)
const style = SyntaxStyle.fromStyles({keyword:{fg:RGBA.fromHex("#FF7B72"),bold:true},default:{fg:RGBA.fromHex("#E6EDF3")}})
Code({content:"const x=1",filetype:"typescript",syntaxStyle:style,streaming:false,width:50,height:10})
// Markdown: MarkdownRenderable({content:"# H1",syntaxStyle,streaming:true,conceal:true})
// Diff: DiffRenderable({view:"unified"|"split",syncScroll:true,diff:"patch",syntaxStyle})

// ScrollBox
ScrollBox({width:40,height:20,scrollY:true,stickyScroll:true,stickyStart:"bottom"|"top",
           viewportCulling:true,scrollbarOptions:{showArrows:true,trackOptions:{foregroundColor:"#7aa2f7"}}})
// Keyboard: ↑↓/pgup/pgdn/home/end; Methods: scrollBy(y)/scrollTo({x,y})/scrollChildIntoView("id")

Others: TextArea TabSelect ASCIIFont({text:"T",font:"tiny"}) LineNumberRenderable({target:code})

Constructs (Declarative API)

Box({width:40,borderStyle:"rounded",padding:1}, Text({content:"Hi"}), Input({placeholder:"..."}))
// VNodes queue method calls: input.focus() → auto-executed when added to tree

function LabeledInput({id,label,pl}) {
  return delegate({focus:`${id}-in`},
    Box({flexDirection:"row"}, Text({content:label}),
    Input({id:`${id}-in`,placeholder:pl,width:20})))
}
// delegate({focus:"child-id"}, vnode) routes methods to child components

function Card({title},...children) {
  return Box({border:true,padding:1,flexDirection:"column"},
    Text({content:title,fg:"#FF0"}), Box({flexDirection:"column"},...children))
}

Flexbox Layout (Yoga)

Box({flexDirection:"row"|"column"|"row-reverse"|"column-reverse",
     justifyContent:"center"|"space-between"|"space-around"|"space-evenly",
     alignItems:"center"|"stretch"|"baseline",
     flexGrow:1,flexShrink:0,flexBasis:100,
     width:"100%"|30,height:"50%"|10,
     position:"absolute",left:10,top:5,right:10,bottom:5,
     padding:2,paddingX:4,paddingTop:1,margin:1,gap:1})
// Responsive resize: r.on("resize",(w,h)=>{w\x3C80&&(container.flexDirection="column")})

React Bindings

// tsconfig: "jsx":"react-jsx","jsxImportSource":"@opentui/react"
import {createRoot} from "@opentui/react"
createRoot(await createCliRenderer()).render(\x3CApp />)
// JSX: \x3Ctext> \x3Cbox> \x3Cscrollbox> \x3Cinput> \x3Ctextarea> \x3Cselect> \x3Ccode> \x3Cdiff> \x3Cmarkdown>
// Style modifiers: \x3Cbold> \x3Citalic> \x3Cunderline> \x3Cinline> \x3Cbr/> \x3Clink>
// Hooks: useRenderer() useKeyboard((k)=>{}) useOnResize((w,h)=>{})
//        useTerminalDimensions() usePaste((e)=>{}) useFocus/useBlur(()=>{})
//        useSelectionHandler((sel)=>{}) useTimeline({duration,loop})

Solid Bindings

// tsconfig: "jsx":"preserve","jsxImportSource":"@opentui/solid"
// bunfig.toml: preload=["@opentui/solid/preload"]
import {render} from "@opentui/solid"
render(()=>\x3CApp />) // snake_case component names: ascii_font tab_select
// Hooks same as React + Portal(\x3CPortal mount={r.root}>), Dynamic(\x3CDynamic component="textarea"/>)
// Build: import solidPlugin from "@opentui/solid/bun-plugin"; Bun.build({plugins:[solidPlugin]})
安全使用建议
Install only if you intend to build OpenTUI-based terminal apps. Review the Bun packages before adding them to a project, but the submitted skill itself is a concise reference guide with no suspicious runtime behavior.
能力评估
Purpose & Capability
The stated purpose is to help build terminal UI applications with OpenTUI, and the artifact content is limited to installation notes and API examples for renderer setup, components, layout, and framework bindings.
Instruction Scope
Instructions are scoped to user-directed development tasks; examples cover normal TUI capabilities such as alternate screen mode, mouse input, focus handling, scrollback, and terminal title changes.
Install Mechanism
The skill suggests user-run Bun package installation commands for @opentui packages and React or Solid bindings, which is expected for a framework guide and not automatic or hidden.
Credentials
Terminal control and package installation are proportionate to building terminal UI applications, with no evidence of credential access, broad filesystem indexing, background workers, or unrelated network behavior.
Persistence & Privilege
No persistence mechanism, privilege escalation, startup hooks, credential/session use, or long-running background behavior is present in the artifact.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install opentui
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /opentui 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
OpenTUI 1.0.0 — Initial Release - Introduces a Zig-native terminal UI framework with TypeScript, React, and Solid bindings. - Provides core components: Text, Box, Input, Select, Code (Tree-sitter), and ScrollBox. - Supports a declarative API with flexible Flexbox layout (powered by Yoga). - Includes event handling, theme, terminal control, and advanced rendering modes. - Production-ready, powering OpenCode; features responsive layouts and modern developer workflows.
元数据
Slug opentui
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

OpenTUI — Native Terminal UI Framework 是什么?

OpenTUI — Zig-native terminal UI framework. Covers installation, renderer, components (Text/Box/Input/Select/Code/ScrollBox), Constructs declarative API, Fle... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 15 次。

如何安装 OpenTUI — Native Terminal UI Framework?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install opentui」即可一键安装,无需额外配置。

OpenTUI — Native Terminal UI Framework 是免费的吗?

是的,OpenTUI — Native Terminal UI Framework 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

OpenTUI — Native Terminal UI Framework 支持哪些平台?

OpenTUI — Native Terminal UI Framework 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 OpenTUI — Native Terminal UI Framework?

由 OpenLark(@openlark)开发并维护,当前版本 v1.0.0。

💬 留言讨论