https://kotlinlang.org logo
#compose
Title
# compose
t

theapache64

02/05/2022, 8:41 AM
Why
Color.White
doesn’t work? but other colors like
Color.Red
or
Color.Blue
works! 🧵
I am trying to change my
TextField
background color to white
Copy code
TextField(
        value = value,
        onValueChange = onValueChange,
        modifier = modifier.background(Color.White),
    )
but it doesn’t work. Any idea ? 🤔 (other colors work though)
a

Ayfri

02/05/2022, 2:58 PM
Have you imported it ?
t

theapache64

02/05/2022, 2:59 PM
Yes.
z

Zach Klippenstein (he/him) [MOD]

02/05/2022, 5:39 PM
What does “work” mean?
t

theapache64

02/05/2022, 5:40 PM
calling
.background(Color.White)
doesn’t do anything.
z

Zach Klippenstein (he/him) [MOD]

02/05/2022, 5:42 PM
Does it work with BasicTextField? Some of the material components do some color matching and so if your theme has White in it i wonder if text field is doing something like that
t

theapache64

02/05/2022, 5:44 PM
ahh.. interesting. let me try with BasicTextField.
UPDATE: It works with
BasicTextField
.
z

Zach Klippenstein (he/him) [MOD]

02/05/2022, 7:48 PM
Is there white in your theme?
t

theapache64

02/05/2022, 8:08 PM
Nope. Here’s a reproducible repo if you want : https://github.com/theapache64/WhiteIssue/
z

Zach Klippenstein (he/him) [MOD]

02/05/2022, 9:19 PM
It looks like TextField has its own colors parameter and there's some color stuff in TextFieldDefaults. I guess that's the way to set the background color
t

theapache64

02/05/2022, 9:21 PM
yeah. i was confused why it doesn’t work for one specific color.
z

Zach Klippenstein (he/him) [MOD]

02/05/2022, 11:13 PM
Me too. Not opening my laptop this weekend tho! 😜
☝🏽 1
😄 2
t

theapache64

02/08/2022, 5:36 AM
update: Replicable code moved to here
5 Views