Skip to content

TUI-Framework

We want to use a framework to build a TUI for our application. We will evaluate the most popular TUI frameworks for Go and choose the one that best fits our needs.

Frameworks

There are many frameworks for building TUI in GO but the main ones are Tview and Bubbletea. They have the most documentation and biggest user bases so we will evaluate these two.

Tview

Tview is a fast, flexible UI framework for building rich terminal applications in Golang. It offers widgets like tables, forms, and modals, making interactive console apps easy to create. Built on tcell, it ensures cross-platform compatibility while handling terminal operations. It works best for UIs with less dynamic updates.

The greates project using tview is k9s

Bubbletea

Bubble Tea is a flexible, reactive framework for building terminal applications in Golang using the Model-Update-View (MVU) architecture. It allows developers to create highly interactive and dynamic UIs by handling asynchronous events and updates seamlessly. Unlike traditional imperative UI frameworks, Bubble Tea promotes a declarative style, where the UI is a function of the application's state. This makes it more flexible for building applications with complex interactions and real-time updates.

As part of the charmbracelet suite, Bubble Tea is well-documented and actively maintained. It is used in popular projects like Superfile. Additionally, Bubble Tea has also great plugins for styling like lipgloss and glamour.

Comparison

Feature Tview Bubble Tea
Architecture 🟠 Imperative 🟢 Declarative
Dynamic UI 🟠 Limited 🟢 Flexible
Documentation 🟢 🟢
Community 🟢 🟢
Templates 🟢 built-in 🟢 extensions like bubbles

Conclusion

We use bubble tea with lipgloss and glamour for styling

With the declarative architecture, simplicity and flexibility of Bubble Tea, we can build a highly interactive and dynamic TUI for our application. Additionally, the availability of plugins like lipgloss and glamour allows us to style our UI easily.