# Bubble Tea — Powerful TUI Framework for Go > Bubble Tea is a powerful little TUI framework for Go based on The Elm Architecture. Build terminal applications with composable components, events, and commands. Part of the Charm ecosystem (Lip Gloss, Gum, Wish, Huh). Powers lazygit, soft-serve, and many CLI tools. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash go get github.com/charmbracelet/bubbletea ``` ```go package main import ( "fmt" tea "github.com/charmbracelet/bubbletea" ) type model struct { choices []string cursor int selected map[int]struct{} } func initialModel() model { return model{ choices: []string{"React", "Vue", "Svelte", "Solid", "Qwik"}, selected: make(map[int]struct{}), } } func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch msg.String() { case "q", "ctrl+c": return m, tea.Quit case "up", "k": if m.cursor > 0 { m.cursor-- } case "down", "j": if m.cursor < len(m.choices)-1 { m.cursor++ } case " ": if _, ok := m.selected[m.cursor]; ok { delete(m.selected, m.cursor) } else { m.selected[m.cursor] = struct{}{} } } } return m, nil } func (m model) View() string { s := "Pick your frameworks:\ \ " for i, choice := range m.choices { cursor := " " if m.cursor == i { cursor = ">" } checked := " " if _, ok := m.selected[i]; ok { checked = "x" } s += fmt.Sprintf("%s [%s] %s\ ", cursor, checked, choice) } return s + "\ q to quit\ " } func main() { tea.NewProgram(initialModel()).Run() } ``` ## Intro Bubble Tea is a Go framework for building terminal user interfaces based on The Elm Architecture (Model-Update-View). Part of the Charm ecosystem that also includes Lip Gloss (styling), Bubbles (components), Gum (CLI scripting), and Huh (forms). Used in lazygit, soft-serve, glow, and many Go CLI tools. - **Repo**: https://github.com/charmbracelet/bubbletea - **Stars**: 41K+ - **Language**: Go - **License**: MIT ## What Bubble Tea Does - **Elm Architecture** — Model, Update, View pattern - **Components** — via Bubbles library (text input, spinner, table, list, paginator) - **Styling** — via Lip Gloss (colors, borders, alignment) - **Mouse support** — click and scroll events - **Async commands** — Cmd pattern for side effects - **Sub-programs** — compose multiple TUI programs - **Renderer** — efficient diff-based terminal rendering - **Cross-platform** — Windows, macOS, Linux ## Comparison | TUI Framework | Language | Architecture | |---|---|---| | Bubble Tea | Go | Elm (MVU) | | Ratatui | Rust | Immediate mode | | Textual | Python | Widget tree | | Ink | TypeScript | React-like | | cursive | Rust | Callback | ## FAQ **Q: What is the Elm Architecture?** A: Unidirectional data flow: Model (state) → View (render) → Update (handle messages) → new Model. Concise and testable. **Q: Relationship with other Charm tools?** A: Bubble Tea is the core framework; Bubbles provides prebuilt components; Lip Gloss handles styling; Gum lets you use Charm components in shell scripts; Huh is a form library. ## Sources - Docs: https://github.com/charmbracelet/bubbletea - GitHub: https://github.com/charmbracelet/bubbletea - License: MIT --- Source: https://tokrepo.com/en/workflows/bubble-tea-powerful-tui-framework-go-42404a64 Author: Charm