# Blessed — High-Level Terminal Interface Library for Node.js > A curses-like library for Node.js that provides a full terminal widget toolkit with mouse support, rendering optimization, and a rich set of UI elements for building interactive command-line applications. ## Install Save as a script file and run: # Blessed — High-Level Terminal Interface Library for Node.js ## Quick Use ```bash npm install blessed const blessed = require('blessed'); const screen = blessed.screen({ smartCSR: true, title: 'My App' }); const box = blessed.box({ top: 'center', left: 'center', width: '50%', height: '50%', content: 'Hello {bold}world{/bold}!', tags: true, border: { type: 'line' }, style: { border: { fg: '#f0f0f0' } } }); screen.append(box); screen.key(['escape', 'q'], () => process.exit(0)); screen.render(); ``` ## Introduction Blessed is a curses-like terminal interface library for Node.js that provides a complete widget system for building interactive CLI applications. It handles terminal rendering, keyboard and mouse input, color support, and layout management, allowing developers to create dashboards, file managers, and interactive tools that run in any terminal emulator. ## What Blessed Does - Provides a widget-based UI system with boxes, lists, tables, forms, and text areas - Handles terminal rendering with intelligent screen diffing to minimize redraws - Supports mouse events including click, scroll, and drag on supported terminals - Manages layouts with absolute, relative, and percentage-based positioning - Renders styled text with markup tags for bold, underline, colors, and backgrounds ## Architecture Overview Blessed abstracts the terminal into a Screen object that manages a tree of widget nodes. Each widget calculates its layout coordinates and renders content to an internal buffer. On each render cycle, Blessed diffs the current buffer against the previous frame and emits only the changed characters as terminal escape sequences. This optimization keeps output fast even for complex interfaces with many overlapping elements. ## Self-Hosting & Configuration - Install via npm and require the blessed module in your Node.js script - Create a screen instance with options for terminal type, smart CSR, and title - Build UI by composing widget instances and appending them to the screen - Bind keyboard shortcuts with screen.key() and widget-level event handlers - Use blessed.program() for lower-level terminal control when needed ## Key Features - 40+ built-in widget types: box, list, table, form, textarea, progress bar, and more - Smart rendering: diffs frames and sends minimal escape sequences for fast updates - Mouse support: click, hover, scroll, and drag events on compatible terminals - Markup-based styling: use inline tags like {bold}, {red-fg}, {underline} in content - 256-color and true-color support with automatic fallback for limited terminals ## Comparison with Similar Tools - **Ink** — React-based terminal UI; component model is more familiar to React developers, but Blessed offers more widget types and lower-level control - **Bubble Tea** — Go library for terminal UIs with Elm-style architecture; choose Blessed if your stack is Node.js - **Textual** — Python-based TUI framework with CSS-like styling; similar scope but for the Python ecosystem - **ncurses** — C library that Blessed draws inspiration from; Blessed is higher-level and JavaScript-native ## FAQ **Q: Is Blessed still maintained?** A: The original repository has limited recent activity. The community fork blessed-contrib adds charts and gauges. For new projects, consider neo-blessed or Ink as alternatives. **Q: Can I use it with TypeScript?** A: Type definitions are available via @types/blessed on npm. The core library is plain JavaScript. **Q: Does it work on Windows?** A: Yes, with limitations. Windows Terminal and ConEmu provide the best compatibility. Some mouse and color features may not work in older Windows console hosts. **Q: How do I handle window resizing?** A: The Screen object emits a resize event. Use percentage-based widget dimensions for automatic layout adaptation, or listen to the event for manual recalculation. ## Sources - https://github.com/chjj/blessed - https://github.com/yaronn/blessed-contrib --- Source: https://tokrepo.com/en/workflows/asset-61dbcde9 Author: Script Depot