_examples
Fix gauge label style to avoid terminal rendering issues
_test
Bump gotui to v5 and update imports and docs
_tools
Improve image example and color accuracy in widgets
drawille
Fork project to gotui with major upgrades
widgets
Fix gauge label style to avoid terminal rendering issues
.gitignore
Refactor: centralize globals and unify color usage
application.go
Refactor backend management and deprecate globals
backend.go
Refactor backend management and deprecate globals
block_events.go
Add Application abstraction and event handling support
block.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
border_merge.go
Add new tests for Block, Grid, and style gradients
borders.go
Add customizable border sets and multi-color gradients
buffer.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
canvas.go
Bump gotui to v5 and update imports and docs
constants.go
Refactor backend management and deprecate globals
CONTRIBUTING.md
Enhance tab and border customization features
doc.go
Add new tests for Block, Grid, and style gradients
events.go
Improve rendering robustness and update documentation
go.mod
Bump gotui to v5 and update imports and docs
go.sum
Bump gotui to v5 and update imports and docs
gotui.gif
Update README with new features and add demo GIF
grid.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
LICENSE.md
Enhance tab and border customization features
logo.png
Add customizable border sets and multi-color gradients
Makefile
Refactor to use Go 1.18+ 'any' and simplify min/max logic
README.md
Add StepChart widget and example
render.go
Add strikethrough modifier and fix alignment offsets
screenshot.go
Add new tests for Block, Grid, and style gradients
style_gradient.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
style_parser.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
style.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
symbols.go
Unify symbol definitions in symbols.go
types.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic
utils.go
Refactor to use Go 1.18+ 'any' and simplify min/max logic

gotui

A modern, high-performance Terminal User Interface (TUI) library for Go.

gotui by Carsen Klock is a fully-customizable dashboard and widget Go library built on top of tcell. It is a modernized enhanced fork of termui, engineered for valid TrueColor support, high-performance rendering, flex layouts, rounded borders, input, and for feature parity with robust libraries like ratatui.


⚡ Features

  • 🚀 High Performance: optimized rendering engine capable of ~3000 FPS frame operations with zero-allocation drawing loops. (termui is ~1700 FPS)
  • 🎨 TrueColor Support: Full 24-bit RGB color support for modern terminals (Ghostty, Alacritty, Kitty, iTerm2).
  • 📐 Flexible Layouts:
    • Flex: Mixed fixed/proportional layouts.
    • Grid: 12-column dynamic grid system.
    • Absolutes: Exact coordinates when needed.
  • 🌐 SSH / Remote Apps: Turn any TUI into a zero-install SSH accessible application (multi-tenant support).
  • 🎨 Gradient Support: Gradient support for widgets.
  • 📊 Rich Widgets:
    • Charts: BarChart, StackedBarChart, PieChart, DonutChart, RadarChart (Spider), FunnelChart, TreeMap, Sparkline, Plot (Scatter/Line).
    • Gauges: Gauge, LineGauge (with pixel-perfect Braille/Block styles).
    • Interaction: Input, TextArea, List, Table, Scrollbar, Button, Checkbox.
    • Misc: TabPane, Image (block-based), Canvas (Braille), Heatmap, Logo, Spinner, Modal.
  • 📱 Application API: Structured app framework with focus management, event dispatch, and auto-resize.
  • 🖱️ Mouse Support: Full mouse event support (Click, Scroll Wheel, Drag).
  • 🔧 Customizable: Themes, rounded borders, border titles (alignment).

🆚 Comparison

Featuregotuitermui
Renderertcell (Optimized)termbox
Performance (FPS)~3300 (Heavy Load)~1700
Widgets Available27+ (Calendar, Tree, Button, Checkbox...)~12
Layout SystemFlex + Grid + AbsoluteGrid
CustomizationHigh (Rounded Borders, Alignments)Basic
Pixel-PerfectYes (Braille/Block/Space)No
Mouse SupportFull (Wheel/Click/Drag)Click
TrueColorYesNo
SSH / Multi-UserNative (Backend API)No (Global State)
Modern Terminal SupportAll (iterm, ghostty, etc.)No

gotui is backward compatible with termui and can mostly be used as a drop-in replacement.

📦 Installation

gotui uses Go modules.

go get github.com/metaspartan/gotui/v5

Requires Go Lang 1.24 or higher.

🚀 Quick Start

Create a main.go:

package main

import (
	"log"

	ui "github.com/metaspartan/gotui/v5"
	"github.com/metaspartan/gotui/v5/widgets"
)

func main() {
	if err := ui.Init(); err != nil {
		log.Fatalf("failed to initialize gotui: %v", err)
	}
	defer ui.Close()

	p := widgets.NewParagraph()
	p.Title = "Hello World"
	p.Text = "PRESS q TO QUIT.\n\nCombined with modern widgets, gotui aims to provide the best TUI experience in Go."
	p.SetRect(0, 0, 50, 5)
	p.TitleStyle.Fg = ui.ColorYellow
	p.BorderStyle.Fg = ui.ColorSkyBlue

	ui.Render(p)

	uiEvents := ui.PollEvents()
	for {
		e := <-uiEvents
		switch e.ID {
		case "q", "<C-c>":
			return
		}
	}
}

📚 Widgets Gallery*

Run the main dashboard demo: go run _examples/dashboard/main.go

Run individual examples: go run _examples/<name>/main.go

*Widget Screenshots are auto generated.

🛠️ Advanced Usage

Application API

For structured applications with focus management and automatic event dispatch:

package main

import (
	"log"
	"github.com/metaspartan/gotui/v5"
	"github.com/metaspartan/gotui/v5/widgets"
)

func main() {
	app := gotui.NewApp()

	p := widgets.NewParagraph()
	p.Title = "My App"
	p.Text = "Press q or Ctrl+C to quit."

	app.SetRoot(p, true) // Set root widget with focus

	if err := app.Run(); err != nil {
		log.Fatal(err)
	}
}

The Application handles:

  • Terminal initialization/cleanup
  • Automatic resize handling
  • Event dispatch to focused widgets
  • Default quit handlers (q, Ctrl+C)

Customizing Borders

gotui supports multiple border styles and title alignments.

p.Border = true
p.BorderRounded = true   // ╭───╮ instead of ┌───┐
p.Title = "My Title"
p.TitleAlignment = ui.AlignLeft // or AlignCenter, AlignRight
p.TitleBottom = "Page 1"
p.TitleBottomAlignment = ui.AlignRight

// Or use other border styles:
double := ui.BorderSetDouble()
p.BorderSet = &double  // ╔═══╗

thick := ui.BorderSetThick()
p.BorderSet = &thick   // ┏━━━┓

Handling Mouse Events

Events include MouseLeft, MouseRight, MouseRelease, MouseWheelUp, MouseWheelDown.

uiEvents := ui.PollEvents()
for e := range uiEvents {
    if e.Type == ui.MouseEvent {
        // e.ID is "MouseLeft", "MouseWheelUp", etc.
        // e.Payload.X, e.Payload.Y are coordinates
    }
}

🌐 Serving over SSH

You can easily serve your TUI over SSH (like standard CLI apps) using ui.InitWithConfig and a library like gliderlabs/ssh.

func sshHandler(sess ssh.Session) {
    // 1. Create a custom backend for this session
    app, err := ui.NewBackend(&ui.InitConfig{
        CustomTTY: sess, // ssh.Session implements io.ReadWriter
    })
    if err != nil {
        return // Handle error appropriately
    }
    defer app.Close()

    // 2. Use the app instance instead of global ui.* functions
    p := widgets.NewParagraph()
    p.Text = "Hello SSH User!"
    p.SetRect(0, 0, 20, 5)
    
    app.Render(p) // Renders to the SSH client only!
}

Check _examples/ssh-dashboard for a full multi-user demo.

🤝 Contributing

Contributions are welcome! Please submit a Pull Request.

  1. Fork the repo.
  2. Create your feature branch (git checkout -b feature/my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin feature/my-new-feature).
  5. Create a new Pull Request.

Projects using gotui

Submit a PR to add yours here!

Author(s)

Carsen Klock (https://x.com/carsenklock)

Zack Guo (https://github.com/gizak)

License

MIT

Acknowledgments

Original termui by Zack Guo.

Inspired by Ratatui.