Skip to content

textinput cursor doesn't have background #897

Open

Description

@Fiend3d

Describe the bug
After migrating to v2, I fixed one issue but introduced two (actually three) new ones. The cursor now has no background color when drawn without text.

Image

Setup

  • OS Windows 10-11
  • Shell Powershell
  • Terminal Emulator Windows Terminal
  • Terminal Multiplexer - none
  • Locale en_US

To Reproduce
Just set a style with a background color for textinput.

Source Code
Here's how I initialize textinput

func newTextinput(style lipgloss.Style, grayColor color.Color) textinput.Model {
	input := textinput.New()
	input.CharLimit = 255 // hello, windows!
	input.SetWidth(0)     // TODO: it's bugged right now, wait until it's fixed and clean up update then
	styles := input.Styles()
	styles.Focused.Text = style
	styles.Focused.Placeholder = style.Foreground(grayColor)
	styles.Focused.Suggestion = style.Foreground(grayColor)
	styles.Focused.Prompt = style.Foreground(grayColor)

	styles.Blurred.Text = style
	styles.Blurred.Placeholder = style.Foreground(grayColor)
	styles.Blurred.Suggestion = style.Foreground(grayColor)
	styles.Blurred.Prompt = style.Foreground(grayColor)

	styles.Cursor.Color = style.GetForeground()
	styles.Cursor.Blink = true
	input.SetStyles(styles)
	return input
}

Expected behavior
It used to draw just fine in v1

Screenshots
It looks like this when there are multiple textinputs:
Image

Additional context
Also, on my Windows 10 machine Alacritty looks completely broken now with v2, it was also fine before.
Image
It shows cursor (right-bottom corner) and Esc doesn't work. It's also messed up.

There is a pull request #892
But it changes the view(). In my opinion the issue is here

// SetStyles sets the styles for the text input.
func (m *Model) SetStyles(s Styles) {
	m.styles = s
	m.updateVirtualCursorStyle()
}

// updateVirtualCursorStyle sets styling on the virtual cursor based on the
// textarea's style settings.
func (m *Model) updateVirtualCursorStyle() {
	if !m.useVirtualCursor {
		// Hide the virtual cursor if we're using a real cursor.
		m.virtualCursor.SetMode(cursor.CursorHide)
		return
	}

	m.virtualCursor.Style = lipgloss.NewStyle().Foreground(m.styles.Cursor.Color)

	// By default, the blink speed of the cursor is set to a default
	// internally.
	if m.styles.Cursor.Blink {
		if m.styles.Cursor.BlinkSpeed > 0 {
			m.virtualCursor.BlinkSpeed = m.styles.Cursor.BlinkSpeed
		}
		m.virtualCursor.SetMode(cursor.CursorBlink)
		return
	}
	m.virtualCursor.SetMode(cursor.CursorStatic)
}

m.virtualCursor.Style = lipgloss.NewStyle().Foreground(m.styles.Cursor.Color) creates a new style, that probably has black background. But I dunno, I haven't tried to fix it. I might be wrong.

Activity

  1. Fiend3d commented on Mar 4, 2026

    @Fiend3d
    Author

    After trying, #892 works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions