How charmbracelet/bubbletea works
Bubble Tea is a Go terminal UI framework implementing an Elm-style event loop: an application supplies a model, initialization command, update logic and declarative view; the runtime reads terminal events, runs commands, updates state and renders frames. The map covers the documented workflow plus terminal input, rendering, command execution and terminal lifecycle. Source excerpts show key runtime and renderer interactions; other capability branches are retained from README documentation, with unverified links left out.
Main entry points: tea.go Program loop · tty.go Input reader · renderer.go Renderer interface · commands.go Commands
Components 21
Application contract
- Model logic
Program runtime
- Program loop
tea.go - Commands
commands.go - Interactive exec
exec.go - Program options
options.go
Terminal I/O
- Input reader
tty.go - Keyboard events
key.go - Mouse events
mouse.go - Renderer interface
renderer.go - Cell renderer
cursed_renderer.go - No-op renderer
nil_renderer.go - Screen output
screen.go - Terminal control
tty.go
Terminal capabilities
- Clipboard
clipboard.go - Color detection
color.go - Color profile
profile.go - Focus handling
focus.go - Bracketed paste
paste.go - Terminal queries
termcap.go
Other components
- App developer
- Terminal user
Connections 26
- App developer → Model logic: implements
README.md - App developer → Program loop: starts
README.md - Program loop → Model logic: updates
README.md - Model logic → Commands: returns commands
README.md - Program loop → Commands: runs
tea.go - Commands → Program loop: sends messages
tea.go - Program loop → Input reader: starts reader
tty.go - Input reader → Program loop: streams events
tty.go - Terminal user → Input reader: generates input
- Input reader → Keyboard events: decodes keys
- Input reader → Mouse events: decodes mouse
- Program loop → Renderer interface: renders views
tea.go - Renderer interface → Cell renderer: implemented by
cursed_renderer.go - Renderer interface → No-op renderer: implemented by
- Cell renderer → Screen output: writes frames
- Program loop → Terminal control: manages terminal
tty.go - Program loop → Interactive exec: dispatches execution
tea.go - Interactive exec → Terminal control: releases and restores
exec.go - App developer → Program options: configures
options.go - Program options → Program loop: sets behavior
options.go - Program loop → Clipboard: handles requests
tea.go - Program loop → Color detection: handles queries
tea.go - Program loop → Color profile: detects profile
- Program loop → Focus handling: reports focus
- Program loop → Bracketed paste: handles paste
- Program loop → Terminal queries: queries capabilities