Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply background on colored text #77

Closed
microo8 opened this issue Apr 7, 2022 · 0 comments
Closed

Apply background on colored text #77

microo8 opened this issue Apr 7, 2022 · 0 comments

Comments

@microo8
Copy link

microo8 commented Apr 7, 2022

When aplying a style with background, it doesn't fill some whitespace after a colored text.
How to do it right?

example:

package main

import (
	"fmt"
	"strings"

	"github.com/charmbracelet/lipgloss"
)

var (
	box = lipgloss.NewStyle().
		Background(lipgloss.Color("237")).
		Padding(2)
	label = lipgloss.NewStyle().
		Foreground(lipgloss.Color("6"))
	text = lipgloss.NewStyle().
		Foreground(lipgloss.Color("9"))
)

func main() {
	var col1, col2 strings.Builder
	col1.WriteString(label.Render("foo:"))
	col1.WriteRune('\n')
	col1.WriteString(label.Render("bar:"))
	col2.WriteString(text.Render("1235"))
	col2.WriteRune('\n')
	col2.WriteString(text.Render("ABC"))
	fmt.Println(
		box.Render(
			lipgloss.JoinHorizontal(
				lipgloss.Bottom,
				col1.String(),
				lipgloss.NewStyle().PaddingLeft(5).Render(col2.String()),
			),
		),
	)
}

output:
screenshot

@charmbracelet charmbracelet locked and limited conversation to collaborators Apr 7, 2022
@meowgorithm meowgorithm converted this issue into discussion #78 Apr 7, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant