Top Related Projects
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.
Minimalist Go package aimed at creating Console User Interfaces.
Golang terminal dashboard
A UI library for terminal applications.
Pure Go termbox implementation
A powerful little TUI framework 🏗
Quick Overview
rivo/tview is a rich interactive widgets library for terminal-based user interfaces in Go. It provides a flexible and powerful set of components for building text-based applications with advanced features like mouse support, color, and flexible layouts.
Pros
- Rich set of pre-built widgets and layouts for rapid development
- Supports both keyboard and mouse input
- Flexible and customizable, allowing for complex UI designs
- Cross-platform compatibility
Cons
- Learning curve for developers new to terminal-based UIs
- Limited to text-based interfaces, not suitable for graphical applications
- May require additional effort for accessibility features
- Performance can be impacted with very large or complex layouts
Code Examples
Creating a simple application with a text view:
package main
import (
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
textView := tview.NewTextView().
SetText("Hello, world!").
SetTextAlign(tview.AlignCenter).
SetTextColor(tcell.ColorGreen)
if err := app.SetRoot(textView, true).Run(); err != nil {
panic(err)
}
}
Creating a form with input fields:
package main
import (
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
form := tview.NewForm().
AddInputField("Name", "", 20, nil, nil).
AddPasswordField("Password", "", 20, '*', nil).
AddButton("Submit", func() {
app.Stop()
})
if err := app.SetRoot(form, true).Run(); err != nil {
panic(err)
}
}
Creating a flex layout with multiple widgets:
package main
import (
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
flex := tview.NewFlex().
AddItem(tview.NewBox().SetBorder(true).SetTitle("Left"), 0, 1, false).
AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
AddItem(tview.NewBox().SetBorder(true).SetTitle("Top"), 0, 1, false).
AddItem(tview.NewBox().SetBorder(true).SetTitle("Bottom"), 0, 1, false), 0, 2, false).
AddItem(tview.NewBox().SetBorder(true).SetTitle("Right"), 0, 1, false)
if err := app.SetRoot(flex, true).Run(); err != nil {
panic(err)
}
}
Getting Started
To use rivo/tview in your Go project:
-
Install the library:
go get github.com/rivo/tview
-
Import it in your Go file:
import "github.com/rivo/tview"
-
Create an application and add widgets:
app := tview.NewApplication() // Add widgets and set up your UI if err := app.Run(); err != nil { panic(err) }
Competitor Comparisons
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.
Pros of tcell
- Lower-level library, offering more fine-grained control over terminal operations
- Supports a wider range of terminal types and platforms
- Generally faster performance due to its lower-level nature
Cons of tcell
- Requires more code to create complex user interfaces
- Steeper learning curve for developers new to terminal-based UIs
- Less built-in support for high-level UI components
Code comparison
tcell (basic screen setup):
screen, err := tcell.NewScreen()
if err != nil {
log.Fatal(err)
}
screen.Init()
tview (basic application setup):
app := tview.NewApplication()
box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
if err := app.SetRoot(box, true).Run(); err != nil {
panic(err)
}
tview is built on top of tcell, providing a higher-level abstraction for creating terminal user interfaces. While tcell offers more control and flexibility, tview simplifies the process of building complex UIs with pre-built components and layouts. tcell is better suited for projects requiring low-level terminal manipulation, while tview is ideal for rapidly developing feature-rich terminal applications with less code.
Minimalist Go package aimed at creating Console User Interfaces.
Pros of gocui
- Simpler API with fewer abstractions, making it easier to get started
- More low-level control over the terminal UI elements
- Smaller codebase, potentially easier to understand and modify
Cons of gocui
- Less feature-rich compared to tview
- Fewer built-in widgets and layout options
- Less active development and community support
Code Comparison
gocui example:
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Panicln(err)
}
defer g.Close()
g.SetManagerFunc(layout)
tview example:
app := tview.NewApplication()
box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
if err := app.SetRoot(box, true).Run(); err != nil {
panic(err)
}
Both libraries provide ways to create terminal user interfaces in Go, but tview offers a higher-level API with more built-in widgets and layout options. gocui provides more low-level control but requires more manual setup. tview is generally more feature-rich and actively maintained, while gocui offers a simpler approach for basic terminal UIs.
Golang terminal dashboard
Pros of termui
- More visually appealing and feature-rich widgets, including charts and graphs
- Better suited for data visualization and dashboard-style applications
- Supports mouse input for interactive elements
Cons of termui
- Less actively maintained, with fewer recent updates
- More complex API, potentially steeper learning curve
- Limited flexibility for custom layouts compared to tview
Code Comparison
termui example:
p := widgets.NewParagraph()
p.Text = "Hello World!"
p.SetRect(0, 0, 25, 5)
ui.Render(p)
tview example:
app := tview.NewApplication()
text := tview.NewTextView().SetText("Hello World!")
app.SetRoot(text, true).Run()
Both libraries offer ways to create terminal user interfaces in Go, but they cater to different use cases. termui excels in creating visually rich dashboards and data visualizations, while tview provides a more flexible and customizable approach for general-purpose terminal applications. The choice between them depends on the specific requirements of your project and the level of control you need over the UI elements.
A UI library for terminal applications.
Pros of tui-go
- Simpler API with fewer concepts to learn
- More flexible layout system using constraints
- Better support for custom widgets and drawing
Cons of tui-go
- Less actively maintained (last commit in 2019)
- Fewer built-in widgets compared to tview
- Limited documentation and examples
Code Comparison
tui-go example:
box := tui.NewVBox(
tui.NewLabel("Hello, world!"),
tui.NewLabel("Press q to quit"),
)
ui, err := tui.New(box)
if err != nil {
log.Fatal(err)
}
tview example:
box := tview.NewBox().
SetBorder(true).
SetTitle("Hello, world!")
app := tview.NewApplication().
SetRoot(box, true)
if err := app.Run(); err != nil {
panic(err)
}
Both libraries provide ways to create terminal user interfaces in Go, but tview offers a more extensive set of widgets and is actively maintained. tui-go has a simpler API and more flexible layout system, but lacks recent updates and comprehensive documentation. tview is generally considered more feature-rich and better supported, making it a more popular choice for complex TUI applications in Go.
Pure Go termbox implementation
Pros of termbox-go
- Lower-level API, offering more fine-grained control over terminal output
- Lightweight and minimal dependencies, suitable for simple terminal applications
- Cross-platform support with consistent behavior across different operating systems
Cons of termbox-go
- Less feature-rich compared to tview, requiring more manual implementation of UI elements
- Steeper learning curve for creating complex terminal user interfaces
- Limited built-in support for advanced text formatting and styling
Code Comparison
termbox-go:
termbox.Init()
defer termbox.Close()
termbox.SetCell(0, 0, 'H', termbox.ColorDefault, termbox.ColorDefault)
termbox.Flush()
tview:
app := tview.NewApplication()
box := tview.NewBox().SetBorder(true).SetTitle("Hello, World!")
app.SetRoot(box, true).Run()
The code comparison demonstrates that tview provides a higher-level abstraction for creating UI elements, while termbox-go requires more manual handling of individual cells and screen updates. tview's approach is more suitable for complex applications, while termbox-go offers greater flexibility for simpler use cases.
A powerful little TUI framework 🏗
Pros of Bubbletea
- More flexible and composable architecture, allowing for easier creation of complex UIs
- Better support for modern Go practices, including context usage and error handling
- Extensive ecosystem of components and tools (Bubbles, Lip Gloss, etc.)
Cons of Bubbletea
- Steeper learning curve, especially for developers new to functional programming concepts
- Less out-of-the-box widgets compared to Tview, requiring more custom implementation
Code Comparison
Bubbletea example:
type model struct{}
func (m model) Init() tea.Cmd { return nil }
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil }
func (m model) View() string { return "Hello, World!" }
Tview example:
app := tview.NewApplication()
text := tview.NewTextView().SetText("Hello, World!")
if err := app.SetRoot(text, true).Run(); err != nil {
panic(err)
}
Bubbletea uses a more functional approach with a model and update cycle, while Tview follows a more traditional object-oriented style with widgets and layouts. Bubbletea's architecture allows for more complex state management, while Tview provides a simpler API for basic UI components.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Rich Interactive Widgets for Terminal UIs
This Go package provides commonly used components for terminal based user interfaces.
Among these components are:
- Input forms (including text input, selections, checkboxes, and buttons)
- Navigable multi-color text views
- Editable multi-line text areas
- Sophisticated navigable table views
- Flexible tree views
- Selectable lists
- Images
- Grid, Flexbox and page layouts
- Modal message windows
- An application wrapper
They come with lots of customization options and can be easily extended to fit your needs.
Usage
To add this package to your project:
go get github.com/rivo/tview@master
Hello World
This basic example creates a box titled "Hello, World!" and displays it in your terminal:
package main
import (
"github.com/rivo/tview"
)
func main() {
box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
panic(err)
}
}
Check out the GitHub Wiki for more examples along with screenshots. Or try the examples in the "demos" subdirectory.
For a presentation highlighting this package, compile and run the program found in the "demos/presentation" subdirectory.
Projects using tview
- K9s - Kubernetes CLI
- IRCCloud Terminal Client
- Window manager for
tview
- CLI bookmark manager
- A caving database interface written in Go
- Interactive file browse and exec any command.
- A complete TUI for LDAP
- A simple CRM
- Terminal UI for todist
- Graphical kubectl wrapper
- Decred Decentralized Exchange
- A CLI file browser for Raspberry PI
- A tool to manage projects.
- A simple app for BMI monitoring
- Stream TIDAL from command line
- Secure solution for fully decentralized password management
- A growing collection of convenient little tools to work with systemd services
- A terminal based browser for Redis written in Go
- First project for the Computer Networks course.
- Test your typing speed in the terminal!
- TUI Client for Docker
- SSH client using certificates signed by HashiCorp Vault
- A go terminal based pos software.
- VMware vCenter Text UI
- Bookmarks on terminal
- A UDP testing utility
- A simple Kanban board for your terminal
- The personal information dashboard for your terminal.
- MySQL database to Golang struct
- Discord, TUI and SIXEL.
- A CLI Audio Player
- GLab, a GitLab CLI tool
- Browse your AWS ECS Clusters in the Terminal
- The CLI Task Manager for Geeks
- Fast disk usage analyzer written in Go
- Multiplayer Chess On Terminal
- Scriptable TUI music player
- MangaDesk : TUI Client for downloading manga to your computer
- Go How Much? a Crypto coin price tracking from terminal
- dbui: Universal CLI for Database Connections
- ssmbrowse: Simple and elegant cli AWS SSM parameter browser
- gobit: binance intelligence terminal
- viddy: A modern watch command
- s3surfer: CLI tool for browsing S3 bucket and download objects interactively
- libgen-tui: A terminal UI for downloading books from Library Genesis
- kubectl-lazy: kubectl plugin to easy to view pod
- podman-tui: podman user interface
- tvxwidgets: tview extra widgets
- Domino card game on terminal
- goaround: Query stackoverflow API and get results on terminal
- resto: a CLI app can send pretty HTTP & API requests with TUI
- twad: a WAD launcher for the terminal
- pacseek: A TUI for searching and installing Arch Linux packages
- 7GUIs demo
- tuihub: A utility hub/dashboard for personal use
- l'oggo: A terminal app for structured log streaming (GCP stack driver, k8s, local streaming)
- reminder: Terminal based interactive app for organising tasks with minimal efforts.
- tufw: A terminal UI for ufw.
- gh: the GitHub CLI
- piptui: Terminal UI to manage pip packages
- cross-clipboard: A cross-platform clipboard sharing
- tui-deck: nextcloud deck frontend
- ktop: A top-like tool for your Kubernetes clusters
- blimp: UI for weather, network latency, application status, & more
- Curly - A simple TUI leveraging curl to test endpoints
- amtui: Alertmanager TUI
- A TUI CLI manager
- PrivateBTC
- play: A TUI playground to experiment with your favorite programs, such as grep, sed, awk, jq and yq
- gorest: Enjoy making HTTP requests in your terminal, just like you do in Insomnia.
- Terminal-based application to listen Radio Stations around the world!
- ntui: A TUI to manage Hashicorp Nomad clusters
- lazysql: A cross-platform TUI database management tool written in Go
- redis-tui: A Redis Text-based UI client in CLI
- fen: File manager
- sqltui: A terminal UI to operate sql and nosql databases
- DBee: Simple database browser
- oddshub: A TUI for sports betting odds
- envolve: Terminal based interactive app for manage enviroment variables
Documentation
Refer to https://pkg.go.dev/github.com/rivo/tview for the package's documentation. Also check out the Wiki.
Dependencies
This package is based on github.com/gdamore/tcell (and its dependencies) as well as on github.com/rivo/uniseg.
Sponsor this Project
Become a Sponsor on GitHub to further this project!
Versioning and Backwards-Compatibility
I try really hard to keep this project backwards compatible. Your software should not break when you upgrade tview
. But this also means that some of its shortcomings that were present in the initial versions will remain. In addition, at least for the time being, you won't find any version tags in this repo. The newest version should be the one to upgrade to. It has all the bugfixes and latest features. Having said that, backwards compatibility may still break when:
- a new version of an imported package (most likely
tcell
) changes in such a way that forces me to make changes intview
as well, - I fix something that I consider a bug, rather than a feature, something that does not work as originally intended,
- I make changes to "internal" interfaces such as
Primitive
. You shouldn't need these interfaces unless you're writing your own primitives fortview
. (Yes, I realize these are public interfaces. This has advantages as well as disadvantages. For the time being, it is what it is.)
Your Feedback
Add your issue here on GitHub. Feel free to get in touch if you have any questions.
Code of Conduct
We follow Golang's Code of Conduct which you can find here.
Top Related Projects
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others.
Minimalist Go package aimed at creating Console User Interfaces.
Golang terminal dashboard
A UI library for terminal applications.
Pure Go termbox implementation
A powerful little TUI framework 🏗
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot