TermDOM 0.1.0
The first release.
TermDOM is a JavaScript library that displays HTML and CSS in the terminal. It draws actual DOM nodes to terminal output and redraws the screen when they mutate, so TUIs and interactive CLIs can be written with vanilla JavaScript or any frontend web framework.
npm install @b9g/termdomimport {TermDOM} from "@b9g/termdom";
const term = new TermDOM();
term.attach();
term.document.body.innerHTML = `<div style="color: green; border: 1px solid">hello</div>`;What's in it:
- A real DOM document with a CSS cascade and a cell-based layout engine: box model, flexbox, tables, and inline layout. One cell is
1chwide and1pxtall. - Stylesheets from
<style>elements andstyleattributes, translated to ANSI color and text decoration. - Keyboard, mouse, focus, and paste events fired on elements, the document, and the window.
<input>,<textarea>,<select>, checkboxes, and radios as shadow-tree widgets with terminal-native looks, restylable with CSS. The caret is the real terminal cursor, so IMEs compose in the field.- CJK, emoji, and combining characters at their correct widths; Hebrew and Arabic in visual order with contextual shaping.
- Scrolling with
window.scrollTo()andelement.scrollIntoView(); the alternate screen viaelement.requestFullscreen(). - Web Components:
customElements.define(),attachShadow(),<slot>,:host. - Drag selection styled with
::selection;navigator.clipboardover OSC 52.
Documentation: https://termdom.org
Guides: https://termdom.org/guides/getting-started/
Compatibility matrix: https://termdom.org/compatibility/
Examples: https://github.com/bikeshaving/termdom/tree/main/examples