Skip to content

Repository files navigation

LazyTui

A component-based Terminal User Interface framework for Go, built on top of gocui and lazycore.

About

LazyTui is a high-level TUI framework designed to reduce the boilerplate required for building terminal applications. As someone who enjoys working with terminal applications, I found myself repeatedly implementing the same patterns for panels, modals, focus management, and layouts. This framework wraps gocui and lazycore to provide a clean, component-based architecture that allows you to focus on building features rather than wrestling with low-level terminal APIs.

Inspired by LazyGit, LazyTui provides a similar component system that makes it easy to create professional, interactive terminal UIs.

Features

  • Component-Based Architecture - Reusable UI components with interface-driven design
  • Built-in Components - Panel, TextPanel, ListPanel, TabPanel, StatusBar, and Modal dialogs
  • Flexible Layout System - Powered by lazycore's box layout engine
  • Focus Management - Automatic focus handling with keyboard and mouse support
  • Background Tasks - Execute long-running tasks with spinner overlay and real-time UI updates
  • Keybinding System - Global and view-specific keybindings with automatic StatusBar display
  • Modal Dialogs - OkOnly, YesNo, and InputModal with colour-coded types
  • Thread-Safe Updates - Safe UI updates from goroutines via App.Refresh()
  • Generic List Items - Type-safe list components with custom data binding
  • Debug Logging - Built-in logging system for development

Installation

go get github.com/DokaDev/lazytui

Requirements:

  • Go 1.21 or higher
  • Terminal with UTF-8 support

Dependencies:

require (
    github.com/jesseduffield/gocui v0.3.1-0.20251002151855-67e0e55ff42a
    github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
)

Quick Start

Here's a minimal example to get started:

package main

import (
    "github.com/jesseduffield/lazycore/pkg/boxlayout"
)

func main() {
    // Create application
    app, _ := NewApp(AppConfig{
        AppName: "MyApp",
        Version: "1.0.0",
    })

    // Create a text panel
    panel := NewTextPanel("main", "Hello LazyTui", "", "", true)
    panel.SetContent("Welcome to LazyTui!\n\nPress 'q' to quit.")

    // Register component and set layout
    app.RegisterComponent(panel)
    app.SetLayoutStrategy(&boxlayout.Box{
        Window: "main",
        Weight: 1,
    })

    // Run application
    app.Run()
}

Demo Application

This repository includes a comprehensive demo application showcasing all framework features:

# Clone the repository
git clone https://github.com/DokaDev/lazytui
cd lazytui

# Run the demo
go run .

The demo includes:

  • Process Monitor - List panel with system process information
  • File Browser - Interactive file system navigation
  • Command Execution - Background tasks with real-time output streaming
  • Activity Log - Real-time logging panel
  • Modal Dialogs - Examples of all modal types
  • Tab Navigation - Multiple tab panels with dynamic content

Default Keybindings

  • q - Quit application
  • / - Switch between panels
  • / - Scroll or navigate lists
  • Tab / Shift+Tab - Switch tabs (in TabPanel)
  • ESC - Close modal dialogs
  • r - Refresh panels
  • m - Show modal examples
  • Mouse support enabled (click to focus, wheel to scroll)

Acknowledgements

LazyTui is built on the excellent work of:

  • gocui by Jesse Duffield - Terminal UI library
  • lazycore by Jesse Duffield - Box layout system
  • Inspired by LazyGit - A fantastic terminal UI for Git

Special thanks to Jesse Duffield for creating and maintaining these foundational libraries.

About

Component-based TUI framework for Go. Build terminal apps like LazyGit with panels, modals, tabs, and background tasks. Wraps gocui & lazycore to reduce boilerplate. Focus on features, not terminal APIs.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Contributors

Languages