TUITemplate

Reusable TUI templates with patterns extracted from LazyGit.

★ 1 star Go 100% Oct 2025
tuitemplate - layout demo
+--- Sidebar ---+--- Main Content --------+
| > Dashboard   |                          |
|   Settings    |  Dynamic layout panels   |
|   Projects    |  resize with terminal    |
|   Help        |  mouse + keyboard nav    |
|               |                          |
+---------------+--------------------------+
 Pattern: LazyGit sidebar + content layout
>

Project Overview

TUITemplate is a collection of reusable Go TUI templates built by studying and extracting patterns from LazyGit, one of the most polished terminal applications ever built. Instead of starting each new TUI from scratch, these templates provide production-ready layouts, navigation patterns, and component compositions.

The project represents the shift from "building things" to "building things that help you build things." After creating TFE and TUIClassics, the patterns became clear -- sidebar+content layouts, tab navigation, modal dialogs, dynamic resizing. TUITemplate captures these as reusable starting points.

{}

Tech Stack

Go
Pure Go templates. Copy, rename, and start building immediately.
Bubble Tea
Elm architecture with nested models for complex multi-panel layouts.
Lipgloss
CSS-like styling with dynamic width/height calculations for responsive layouts.
Bubbles
List, viewport, text input, and table components pre-wired into templates.
#

Architecture

  LazyGit-Inspired Template Patterns
  ====================================

  Template 1: Sidebar + Content
  Extracted from LazyGit's panel system
  - Focus management between panels
  - Dynamic width ratios
  - Keyboard + mouse panel switching

  Template 2: Tab Layout
  Top tabs with per-tab content models
  - Tab state isolation
  - Shared status bar
  - Tab-specific keybindings

  Template 3: Modal Dialog
  Overlay system for confirmations/inputs
  - Focus trapping
  - Backdrop rendering
  - Return-to-previous state
*

Key Features

Dynamic Layouts
Panels resize proportionally with the terminal window. No hardcoded widths -- everything adapts.
Mouse Support
Click to focus panels, scroll within viewports, and interact with list items. Full mouse event handling.
LazyGit Patterns
Panel focus cycling, context-aware keybindings, status bar with mode display. All extracted from studying LazyGit source.
Nested Models
Each panel is its own Bubble Tea model with independent state. Parent model coordinates focus and messaging.
Template Starter
Copy a template directory, rename the module, and you have a working TUI app in seconds.
Responsive Design
WindowSizeMsg handling propagates to all child models. Layouts recalculate on every resize event.
~

Stats

1
Star
100%
Go
12.2
MB Size
Oct 20
Created 2025
3+
Templates
!

Lessons Learned

Studying open source code is underrated. Reading LazyGit's source taught more about TUI architecture than any tutorial. Extracting reusable patterns from real production code and turning them into templates was the bridge between "I can build a thing" and "I can build things efficiently." Template-based development means the boring parts are solved once, and you spend all your time on what makes each project unique.