Open-Source Wikis

/

Bubble Tea

/

Packages

/

Tutorials

charmbracelet/bubbletea

Tutorials

Active contributors: meowgorithm, aymanbagabas

The tutorials/ directory is a separate Go module containing two annotated example programs that step through Bubble Tea's mental model.

tutorials/basics

The grocery-list app from the README. tutorials/basics/main.go is a fully-commented walkthrough of Init, Update, and View. Each block in the README's "Tutorial" section corresponds to a labelled section in the source.

Run it:

cd tutorials
go run ./basics

Highlights:

  • Defines model as a struct with choices, cursor, and selected.
  • Returns nil from Init (no I/O on startup).
  • Switches on tea.KeyPressMsg in Update for up, down, enter, space, q, ctrl+c.
  • Sets View.WindowTitle = "Grocery List" to demonstrate the declarative view fields.

tutorials/commands

Extends the grocery-list app with an HTTP request that fetches a fake API. Demonstrates tea.Cmd, tea.Tick, and how I/O fits into the loop.

cd tutorials
go run ./commands

Highlights:

  • Defines a custom statusMsg and errMsg.
  • Returns a tea.Cmd from Init that performs an HTTP GET and produces one of those messages.
  • Renders three states: loading, success, error.

Module layout

tutorials/
├── go.mod
├── go.sum
├── basics/main.go
└── commands/main.go

The module is untagged and not published — its only consumers are the two main.go files and CI.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Tutorials – Bubble Tea wiki | Factory