buffalo-tui
v1.0.3
Published
A beginner friendly TUI framework available on various package managers for Node.js projects
Readme
Buffalo TUI Framework
A beginner friendly TUI framework available on various package managers for Node.js projects.
Features
- Floating Windows are movable, overlapping windows with ZIndex support.
- RGB Color Support allows for full 24-bit RGB coloring with ANSI escape sequences.
- Input Handling gives native keyboard event handling.
- Interactive Elements such as input fields, buttons, and labels with support for keyboard navigation.
- Control Bar allows you to write a useful status bar with nice keyboard shortcuts.
- Efficient Rendering uses a buffer-based rendering system for seamless render updates.
Install Buffalo
Buffalo is available for anyone on the NPM marketplace.
[!NOTE] As of Tuesday, February 10th, 2026, Buffalo does not support TypeScript type declarations!
Install Buffalo using the Node Package Manager:
npm install buffalo-tuiDemo Preview
Getting Started
Writing your first TUI with Buffalo is extremely easy and can be done using the code below:
import { Screen, Frame, ColorManager, InputManager } from "buffalo-tui";
const screen = new Screen();
const inputManager = new InputManager();
screen.enterFullscreen();
// (sizeX, sizeY, posX, posY, windowTitle, color)
const frame = new Frame(
50, 20,
5, 2,
"My Buffalo Program",
new ColorManager().setColor(100, 150, 255)
);
frame.setBackgroundColor(15, 15, 25);
frame.addContent(2, 2, "Hello, Buffalo!", new ColorManager().setColor(255, 255, 100));
screen.addElement(frame);
screen.setControlBar("Press Q to quit");
inputManager.onAny((keyName) => {
if (keyName === "q" || keyName === "Q") {
inputManager.stop();
screen.exitFullscreen();
process.exit(0);
}
});
inputManager.start();
screen.render();Learn Buffalo through API Documentation
Screen
Main class for managing the terminal display.
const screen = new Screen();Properties:
width- Terminal width in charactersheight- Terminal height in characterselements- Array of elements to render
Methods:
enterFullscreen()- Enter fullscreen modeexitFullscreen()- Exit fullscreen moderender()- Render all elements to terminaladdElement(element)- Add an element to the screenremoveElement(element)- Remove an elementsetControlBar(text)- Set control bar textwriteAt(x, y, char, color)- Write a single characterwriteString(x, y, str, color)- Write a stringdrawRect(x, y, width, height, filled, char, color)- Draw a rectangledrawLine(x1, y1, x2, y2, char, color)- Draw a linegetUsableHeight()- Get height minus control bar
Frame
Floating window element with border, title, and content.
Constructor:
new Frame(sizeX, sizeY, posX, posY, windowTitle, borderColor)Parameters:
sizeX- Width of the framesizeY- Height of the frameposX- X position on screenposY- Y position on screenwindowTitle- Title displayed on top borderborderColor- ColorManager instance for border
Methods:
setWindowTitle(title)- Update window titlesetBorderColor(R, G, B)- Set border color (0-255 RGB)setBackgroundColor(R, G, B)- Set background coloraddContent(x, y, text, color)- Add text content at positionclearContent()- Remove all contentshow()- Make frame visiblehide()- Make frame invisiblesetZIndex(z)- Set layering order (higher = front)
Input
Text input field element.
Constructor:
new Input(posX, posY, width, label, color)Parameters:
posX- X position on screenposY- Y position on screenwidth- Width of input fieldlabel- Label text above inputcolor- ColorManager instance (optional)
Methods:
setValue(value)- Set input valuegetValue()- Get current valuesetFocus(focused)- Set focus stateshow()/hide()- Visibility control
Button
Clickable button element.
Constructor:
new Button(posX, posY, text, color)Parameters:
posX- X position on screenposY- Y position on screentext- Button textcolor- ColorManager instance (optional)
Methods:
setText(text)- Update button textsetHovered(hovered)- Set hover stateshow()/hide()- Visibility control
Label
Static text label element.
Constructor:
new Label(posX, posY, text, color)Parameters:
posX- X position on screenposY- Y position on screentext- Label textcolor- ColorManager instance (optional)
Methods:
setText(text)- Update label textsetColor(R, G, B)- Set text colorshow()/hide()- Visibility control
ColorManager
RGB color management with ANSI conversion.
Methods:
setColor(R, G, B)- Set RGB color (0-255 each)getColor()- Returns{R, G, B}objecttoANSIForeground()- Convert to ANSI foreground codetoANSIBackground()- Convert to ANSI background codestatic reset()- Get ANSI reset code
InputManager
Keyboard input handling.
Methods:
start()- Start capturing keyboard inputstop()- Stop capturing inputonAny(callback)- Register callback for any key:(keyName, rawKey) => {}
Key Events:
keyName- Human-readable key namerawKey- Raw escape sequence
