tui-layout
Skill3 starsChanged 8 months agoMITView on GitHub
Full-screen TUI layout patterns for BubbleTea v2 and Lipgloss v2. Use when building or modifying View() layouts, panel sizing, container alignment, or responsive terminal UI structure. Triggers on viewNormal, JoinVertical, JoinHorizontal, Width, Height, panelRows, WindowSizeMsg handling, or any layout calculation.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- masonhuemmer/dopsword for word, first seen Mar 24, 2026
Other versions1 project uses a version of this.
Word for word · 1
- masonhuemmer/dops★ 3100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- bubbletea-patternsSkill
- charm-stylingSkill
- clean-code-boundariesSkill
- clean-code-designSkill
- clean-code-errorsSkill
- clean-code-functionsSkill
- clean-code-namingSkill
- clean-code-solidSkill
- clean-code-testingSkill
- cli-structureSkill
- create-runbookSkill
- demo-recordingSkill
- mutation-testingSkill
- shell-scriptsSkill
- spec-workflowSkill
- tdd-workflowSkill
- tui-testingSkill
- wizard-formsSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 60
Always render auto-height components first, then measure with lipgloss.Height():
- Very specific: line 69
Never hardcode heights like metaH := 8.
- Distinctive: line 72
When two columns must align, force them to the same height:
- Very specific: line 90
Always wrap the final composed content in Width(m.width).Height(m.height):
- Distinctive: line 102
Don't let panels touch the terminal edge:
- Very specific: line 127
Use GetHorizontalFrameSize() / GetVerticalFrameSize() for precise accounting
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TUI Layout Pattern (OpenCode Style)
Full-screen BubbleTea v2 layouts follow a root compositor pattern. There is no explicit "outer frame widget" — the root View() method IS the outer container.
Core Pattern
func (m model) View() tea.View {
// 1. Guard: don't render until terminal size is known
if m.width == 0 || m.height == 0 {
v := tea.NewView("")
v.AltScreen = true
return v
}
// 2. Build panels from budget
content := m.buildLayout()
// 3. Outer container: enforce exact terminal dimensions
content = lipgloss.NewStyle().
Width(m.width).
Height(m.height).
Render(content)
v := tea.NewView(content)
v.AltScreen = true
return v
}Layout Budget
Work top-down from the known terminal size:
m.height (total rows)
├── panelRows = m.height - footerH
│ ├── sidebar (left): Height = panelRows
│ └── right panel: Height = panelRows (forced)
│ ├── metadata: auto-height (measured)
│ └── output: fills remaining
└── footer: footerH rows
m.width (total cols)
├── margin (left + right)
├── sidebar: sw + 2 (border)
├── gap: 1
└── right panel: remainingRules
1. Measure, don't guess
Always render auto-height components first, then measure with lipgloss.Height():
metaView := buildMetadata(...)
metaActualH := lipgloss.Height(metaView) // includes borders, padding, ANSI
outputH := panelRows - metaActualH - 2 // remainder for outputNever hardcode heights like metaH := 8. Content, borders, and line wrapping can change the actual rendered height.
2. Force matching heights with Width/Height
When two columns must align, force them to the same height:
// Right panel forced to exact panelRows
rightPanel = lipgloss.NewStyle().
Height(panelRows).
Width(rightW).
Render(rightPanel)
// Sidebar also panelRows (contentH + 2 border = panelRows)
sidebarView = lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
Width(sw).
Height(panelRows - 2).
Render(sidebarContent)3. Outer container is mandatory
Always wrap the final composed content in Width(m.width).Height(m.height):
content = lipgloss.NewStyle().
Width(m.width).
Height(m.height).
Render(content)This prevents overflow, fills remaining space, and ensures consistent rendering in alt screen. Without it, content may clip, shift, or leave gaps.
4. Use margins for centering
Don't let panels touch the terminal edge:
margin := 1
innerW := m.width - (margin * 2)
// ... compute panel widths from innerW ...
body = lipgloss.NewStyle().
MarginLeft(margin).
Render(body)5. Size propagation is manual
Each child component must receive its allocated dimensions explicitly. Use SetSize(), SetHeight(), or pass dimensions via constructor/method:
m.sidebar.SetHeight(sidebarContentH)
outputView := m.output.ViewWithSize(rightW, outputContentH)6. Border accounting
Lipgloss borders add rows/cols to the rendered output:
Border(RoundedBorder())adds 2 rows (top + bottom) and 2 cols (left + right)- Content width inside border =
Widthvalue - Rendered width =
Width+ 2 - Use
GetHorizontalFrameSize()/GetVerticalFrameSize()for precise accounting
7. JoinHorizontal aligns at the top
lipgloss.JoinHorizontal(lipgloss.Top, left, right) aligns columns at their first row. If one column is shorter, it leaves blank space at the bottom. To align bottoms, both columns must have the same height (see rule 2).
Anti-Patterns
- Don't use padding/newlines to push footer down — use the outer container
Heightinstead - Don't hardcode panel heights — derive from
m.heightand measured components - Don't rely on
MaxHeightfor clipping — it clips from the bottom, hiding footers - Don't compute layout in Update() — compute in View() from current width/height
- Don't skip the outer container — without
Width.Height, alt screen layouts break
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

