[GH-ISSUE #716] Setting a form field's background color does not apply when there is a placeholder #524

Closed
opened 2026-03-04 01:05:44 +03:00 by kerem · 1 comment
Owner

Originally created by @beeb on GitHub (Mar 23, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/716

Consider the following example:

form := tview.NewForm()
form.SetFieldBackgroundColor(tcell.ColorWhite).SetFieldTextColor(tcell.ColorBlack)
form.AddFormItem(tview.NewInputField().SetLabel("field1").SetPlaceHolder("foo").SetPlaceholderTextColor(tcell.ColorDarkGrey))
form.AddFormItem(tview.NewInputField().SetLabel("field2"))

The second field will show the white background color, but the first field with a placeholder shows a different background color until some text is written in the field.

There is no function SetPlaceholderBackgroundColor() which could help in this case.

image

Originally created by @beeb on GitHub (Mar 23, 2022). Original GitHub issue: https://github.com/rivo/tview/issues/716 Consider the following example: ```go form := tview.NewForm() form.SetFieldBackgroundColor(tcell.ColorWhite).SetFieldTextColor(tcell.ColorBlack) form.AddFormItem(tview.NewInputField().SetLabel("field1").SetPlaceHolder("foo").SetPlaceholderTextColor(tcell.ColorDarkGrey)) form.AddFormItem(tview.NewInputField().SetLabel("field2")) ``` The second field will show the white background color, but the first field with a placeholder shows a different background color until some text is written in the field. There is no function `SetPlaceholderBackgroundColor()` which could help in this case. ![image](https://user-images.githubusercontent.com/703631/159707913-bd74c441-5b7a-43c4-af97-b5865614c049.png)
kerem closed this issue 2026-03-04 01:05:44 +03:00
Author
Owner

@rivo commented on GitHub (Apr 15, 2022):

You can use SetPlaceholderStyle() for this.

<!-- gh-comment-id:1100279364 --> @rivo commented on GitHub (Apr 15, 2022): You can use [`SetPlaceholderStyle()`](https://pkg.go.dev/github.com/rivo/tview#InputField.SetPlaceholderStyle) for this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#524
No description provided.