blessed-contrib is a JavaScript library designed for creating rich terminal dashboards and other console-based applications using ASCII/ANSI art. It extends the core `blessed` library, providing a suite of custom widgets such as line charts, bar charts, gauges, LCD displays, tables, and maps, some of which leverage `node-drawille` for advanced graphics. The current stable version is 4.11.0, with releases occurring irregularly, typically annually or semi-annually, focusing on stability. Its key differentiators include a comprehensive set of data visualization widgets tailored for the terminal, seamless integration with `blessed`'s powerful screen management, and explicit support across Linux, OS X, and Windows (with specific prerequisites for the latter). It aims to provide developer-friendly tools for creating visually engaging command-line interfaces.
npm install blessed-contribVerified import paths — ran on the pinned version, not inferred.
This example sets up a `blessed` screen, uses `blessed-contrib`'s grid layout, and displays a line chart and a bar chart with sample data. It also includes essential keybindings for graceful exit.
For CJS environments: `const contrib = require('blessed-contrib');`. For TypeScript/ESM projects, use `import * as contrib from 'blessed-contrib';` and ensure `esModuleInterop` is enabled in your `tsconfig.json`.Always call `screen.append(widget)` or `grid.set(...)` before any `widget.setData()` calls. E.g., `screen.append(line); line.setData([...]);`
Refer to the blessed-contrib documentation or linked resources for Windows setup instructions, typically involving installation of a robust terminal emulator or Git Bash.
Maintain regular updates to the latest minor/patch versions. Always test against new major versions of `blessed` as `blessed-contrib` is tightly coupled.
If running in an ESM environment, use `import * as contrib from 'blessed-contrib';` or ensure your build system/Node.js setup correctly transpiles or handles CommonJS interop. Alternatively, ensure your file is treated as CommonJS (e.g., `.cjs` extension or `"type": "commonjs"` in package.json).
Verify that `const contrib = require('blessed-contrib');` executed successfully and that the `blessed-contrib` package is installed. Ensure no typos in the `contrib` variable name.Ensure `screen.append(widget)` or `grid.set(...)` is called for the widget instance before any subsequent calls to `widget.setData()` or other methods that require it to be rendered.
Always call `screen.render()` at the end of your setup to draw the UI. Implement `screen.key(['escape', 'q', 'C-c'], () => process.exit(0));` or similar to keep the application running until a specific exit command.