Skip to content
Updated April 2026Edit this page ↗

Core

Everything in TermUI sits on top of @termuijs/core. It handles the screen buffer, input decoding, layout computation, style data, events, and the application lifecycle.

If you only install one package, this is it.

Installation

TERMINAL
npm install @termuijs/core

What's inside

ExportWhat it does
AppWires terminal, input, screen, and render loop together
ScreenDouble-buffered cell grid with diff-based rendering
RendererDiffs screen buffers and flushes changes to stdout
TerminalRaw mode, alt screen, cursor control, resize events
InputParserDecodes raw stdin bytes into key and mouse events
EventEmitterType-safe publish/subscribe
FocusManagerTab-order focus cycling across widgets
createLayoutNode / computeLayoutFlexbox-inspired layout engine
defaultStyle / mergeStylesStyle objects. colors, bold, dim, underline
parseColorNamed, hex, and RGB color parsing
stringWidth / truncate / wordWrapUnicode-aware string measurement and wrapping

Quick example

TYPESCRIPT
import { App } from '@termuijs/core'
import { Box, Text } from '@termuijs/widgets'
 
const root = new Box({ border: 'round', padding: 1 })
root.addChild(new Text('Hello, TermUI!', { bold: true }))
 
const app = new App(root)
 
app.events.on('key', (event) => {
    if (event.key === 'q') app.exit()
})
 
await app.mount()

How other packages use core

  • @termuijs/widgets renders into the Screen buffer and uses the layout engine for positioning
  • @termuijs/tss builds on top of the Style interface, adding CSS-like variables and themes
  • @termuijs/router plugs into the App lifecycle for screen transitions
  • @termuijs/motion animates style properties through the render loop