| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- ---
- title: Getting started
- description: Install OpenTUI and create your first terminal UI
- order: 1
- navTitle: Introduction
- skill:
- entry: true
- intents: [getting-started, installation, quickstart, intro]
- ---
- # Getting started
- OpenTUI is a native terminal UI core written in Zig with TypeScript bindings. The native core exposes a C ABI and can be used from any language. OpenTUI powers OpenCode in production today and will also power terminal.shop. It is an extensible core with a focus on correctness, stability, and high performance. It provides a component-based architecture with flexible layout capabilities, allowing you to create complex terminal applications.
- ## Installation
- OpenTUI is currently [Bun](https://bun.sh) exclusive but Deno and Node support in-progress.
- ```bash
- mkdir my-tui && cd my-tui
- bun init -y
- bun add @opentui/core
- ```
- ## Hello world
- Create `index.ts`:
- ```typescript
- import { createCliRenderer, Text } from "@opentui/core"
- const renderer = await createCliRenderer({
- exitOnCtrlC: true,
- })
- renderer.root.add(
- Text({
- content: "Hello, OpenTUI!",
- fg: "#00FF00",
- }),
- )
- ```
- Run it:
- ```bash
- bun index.ts
- ```
- You should see green text. Press `Ctrl+C` to exit.
- ## Composing components
- Components nest naturally. Here's a bordered panel with content:
- ```typescript
- import { createCliRenderer, Box, Text } from "@opentui/core"
- const renderer = await createCliRenderer({
- exitOnCtrlC: true,
- })
- renderer.root.add(
- Box(
- { borderStyle: "rounded", padding: 1, flexDirection: "column", gap: 1 },
- Text({ content: "Welcome", fg: "#FFFF00" }),
- Text({ content: "Press Ctrl+C to exit" }),
- ),
- )
- ```
- `Box` and `Text` are factory functions. The first argument is props; additional arguments are children.
- ## What's next
- ### Core concepts
- - [Renderer](/docs/core-concepts/renderer) - The rendering engine
- - [Layout](/docs/core-concepts/layout) - Flexbox positioning
- - [Constructs](/docs/core-concepts/constructs) - The declarative component API
- ### Components
- - [Text](/docs/components/text), [Box](/docs/components/box) - Display and layout
- - [Input](/docs/components/input), [Select](/docs/components/select) - User interaction
- ### Framework bindings
- - [React](/docs/bindings/react)
- - [Solid.js](/docs/bindings/solid)
|