charmbracelet / bubbles

TUI components for Bubble Tea 🫧
MIT License
5.11k stars 235 forks source link

styled placeholders #517

Open simonasGit opened 2 months ago

simonasGit commented 2 months ago
m.input.SetValue(lipgloss.NewStyle().
Background(lipgloss.Color("#00ff00")).
Render("hah"))

image Instead of using textinput.Model.TextStyle to style the whole text, one may want to only style certain words for example.

I think it might be in styleText because escape sequences are being applied to a lipgloss styled string.

meowgorithm commented 2 months ago

Thanks for the issue! So as a baseline, we should definitely strip ansi from placeholders. Then the question becomes: should we allow placeholders to be styled as well? I think so.

simonasGit commented 2 months ago

Yeah I guess if PlaceholderStyle and TextStyle are deprecated, if one wants a style for the whole string - m.ti.Placeholder = style.Render(text) or

func (m model) View() string {
    v := style.Render(m.ti.Value())
        m.ti.SetValue(v)
    return m.ti.View()
}