How Declarative Views work in Bubble Tea v2
mainIn v2, Bubble Tea moves from imperative commands (e.g., sending a command to enter the alt screen) to declarative View fields.
Instead of configuring the program at startup or sending commands during Update, you define the desired terminal state by setting fields on a tea.View struct within your View() method. Bubble Tea then reconciles this state with the terminal.
Common fields in tea.View include:
AltScreen: Enter/exit the alternate screen buffer.MouseMode: Set totea.MouseModeNone,tea.MouseModeCellMotion, ortea.MouseModeAllMotion.Cursor: Control position, shape, and color.WindowTitle: Set the terminal window title.ReportFocus: Enable focus/blur event reporting.
// v2: declarative — everything lives in View()
func (m model) View() tea.View {
v := tea.NewView("Hello!")
v.AltScreen = true
v.MouseMode = tea.MouseModeCellMotion
return v
}