# Bubbletea and stacking styles with Lipgloss?

**URL:** <https://forum.golangbridge.org/t/bubbletea-and-stacking-styles-with-lipgloss/39271>\
**Category:** Code Review\
**Created:** [July 13, 2025, 5:36am UTC](https://forum.golangbridge.org/t/bubbletea-and-stacking-styles-with-lipgloss/39271 "2025-07-13T05:36:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![torimus](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/torimus/32/15223_2.png) [@torimus](https://forum.golangbridge.org/u/torimus)\
**Post date:** [July 13, 2025, 5:36am UTC](https://forum.golangbridge.org/t/bubbletea-and-stacking-styles-with-lipgloss/39271/1 "2025-07-13T05:36:40Z")

</div>

_want to achieve:_ Produce colored output over other colored output, with underlying uncovered output preserved.

_my attempt:_ bellow, where `model` is Bubbletea’s model interface implementation

```go
import gloss "github.com/charmbracelet/lipgloss"

func (m model) View() string {
	diagStyle := gloss.NewStyle().
		Background(gloss.Color("#0000aa"))
	r1Style := gloss.NewStyle().
		Inherit(diagStyle).
		Foreground(gloss.Color("#ffff00"))
	r2Style := gloss.NewStyle().
		Inherit(diagStyle).
		Foreground(gloss.Color("#ff0000"))
	r3Style := gloss.NewStyle().
		Inherit(diagStyle).
		Foreground(gloss.Color("#ffffff"))
	out := diagStyle.
		Width(30).
		Height(5).
		Padding(1, 2).
		Render(
			gloss.JoinVertical(gloss.Left,
				r1Style.Render("Alice"),
				r2Style.Render("Bob"),
				r3Style.Render("Charlie"),
			),
		)
	return out
}

```

_produces following output with artifacts:_

 ![image](https://forum.golangbridge.org/uploads/default/original/3X/f/b/fb82fac5d38e6b4f4935832f8ed5bbe1ba42ada6.png)

How to fix it, to preserve blueish background color of underlying `diagStyle`? (after Alice and Bob)

---

<div class="post-metadata">

**Author:** ![adsr303](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/adsr303/32/15041_2.png) [@adsr303](https://forum.golangbridge.org/u/adsr303)\
**Post date:** [July 13, 2025, 7:22pm UTC](https://forum.golangbridge.org/t/bubbletea-and-stacking-styles-with-lipgloss/39271/2 "2025-07-13T19:22:10Z")

</div>

I think it would help to analyze what happens with the ANSI codes emitted by the program. I’m pretty sure that `r1Style.Render("Alice")` etc. emit a reset code after the string and `diagStyle` only reverts the background to blue outside the box rendered by `JoinVertical`. I would also test what happens when you align right or center.

Anyway, how I’d try to fix it:

- Pad the strings with spaces.
- Use a lipgloss table instead of `JoinVertical`, styled with blue background and no borders.

You could also submit a lipgloss issue with this example. It is more intuitive to have transparent padding in `JoinVertical`, although in the light of my hypothesis above it may not be trivial to implement.

---

<div class="post-metadata">

**Author:** ![torimus](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/torimus/32/15223_2.png) [@torimus](https://forum.golangbridge.org/u/torimus)\
**Post date:** [August 21, 2025, 5:33am UTC](https://forum.golangbridge.org/t/bubbletea-and-stacking-styles-with-lipgloss/39271/3 "2025-08-21T05:33:34Z")

</div>

Notice for anyone who landed here with similar issue:

Reason why it does not work is because Lipgloss library is **2D only**.  
Stacking styles over other is simply not implemented. Logic for overlapping content is absent. If you plan to create dialog over dialogs TUI then you are either on your own or rather move elsewhere..

---

<div class="post-metadata">

**Author:** ![torimus](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/torimus/32/15223_2.png) [@torimus](https://forum.golangbridge.org/u/torimus)\
**Post date:** [August 22, 2025, 8:19pm UTC](https://forum.golangbridge.org/t/bubbletea-and-stacking-styles-with-lipgloss/39271/4 "2025-08-22T20:19:03Z")

</div>

Good news,

forthcoming major version 2 does finally introduce 3D logic for overlapping of styles (compositing layers):

> **[Release v2.0.0-beta.2 · charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss/releases/tag/v2.0.0-beta.2)**
>
> So Hot Right Now: Lip Gloss v2 Beta 2
> This release builds on top of the last beta 1 release. It includes a new API for compositing layers and views, table enhancements, and a bunch of bug fixes. Le...
