Overview
Bubble Tea provides a flexible rendering system that allows you to customize how your application renders to the terminal, or even disable rendering entirely for non-TUI applications.Renderer Interface
Therenderer interface defines the contract that all renderers must implement:
Built-in Renderers
Bubble Tea includes two built-in renderer implementations:Cursed Renderer
The default renderer (cursedRenderer) provides full-featured terminal rendering:
- Cell-based rendering: Uses a screen buffer (
uv.ScreenBuffer) for efficient updates - Synchronized updates: Supports ANSI synchronized output mode (mode 2026)
- Cursor optimizations: Optional hard tabs and backspace optimizations
- Unicode support: Handles grapheme width calculations
- Mouse support: Full mouse event handling
- Alt screen: Supports alternate screen buffer
Nil Renderer
The nil renderer is a no-op implementation that discards all rendering operations. It’s automatically used when rendering is disabled.Disabling the Renderer
Use
WithoutRenderer when building CLI tools or daemons that use Bubble Tea’s architecture without a TUI.WithoutRenderer option:
Use Cases for WithoutRenderer
Daemon Mode
Run Bubble Tea programs as background services without a TUI
Non-TTY Output
Provide a plain output mode when stdout is not a terminal
Testing
Simplify testing by avoiding terminal complexity
Logging
Use Bubble Tea’s architecture for structured logging tools
Conditional Rendering
You can conditionally enable rendering based on whether output is a TTY:Output Behavior with WithoutRenderer
When the renderer is disabled:- View output: The
View()method is still called, but output is not rendered - Print functions:
tea.Println()andtea.Printf()work normally, sending output to stdout - Input handling: Input processing continues to work
- Terminal modes: No terminal mode changes (raw mode, alt screen, etc.)
- Clean output: Ideal for piping to files or other programs
Custom Renderer Implementation
To implement a custom renderer, create a type that satisfies therenderer interface:
Related Options
- Performance Options - Configure FPS and rendering optimizations
- Middleware - Filter and transform messages before rendering
- WithOutput - Redirect output to custom writers