Change color of reveal password icon
How to change the color of the 'reveal password' icon? Simply calling
->suffixIconColor(...)
after ->revealable()
does not work. Not sure if this is a bug or not. Anyone got an idea on how to fix this?22 Replies
I think the reveal icon is separate to the suffix icon so that doesn't work.
@Dennis Koch I figured. It's an action. But can I mutate the color after an action has been defined?
Not sure whether you can access it from the outside.
Just looking for a way to gain control over this icon... color/change it/etc..
Can I override the icon itself and leaving the action intact?
Just looking at the code: You can try to set the actions manually:
@Dennis Koch you mean not using
->revealable()
but just copy the action of reveable and use it manually, and then change the icon color?
Guess that's a way to do it. Maybe a good idea to put this on the roadmap "gain more control over password revealable"?Yes. Check the source code of
->revealable()
. It's pretty much the code I posted above.yeah I saw it.. was trying to prevent that, but for now ill do it like that
@Dennis Koch made a mixin.. this works fine!
One thing though,
$this->isRevealable
is protected. It works fine, but it isn't nice. I suggest making this public.Why aren't you using the prebuilt
Show/HidePasswordActions
?not working when wanting to change the icon and/or color
ShowPasswordAction::make()->color(...)
is not working?nope
Hm. That's weird.
I assume its because there is already
->color
in that actionThe latter one should overwrite the first one
Thats what I tought, but for some reason it doesnt
it actually removes the icon completely
are you sure
setup()
is being called when we use TextInput\Actions\ShowPasswordAction::make()
Yes. It's part of
configure()
which is called immediately after new ...
inside make
this is the problem with your solution:
its correct, but its now hiding the icon
with your solution
$this->isRevealable = true
isnt called
because that lives in the ->revealable()
got it working now.. like you said, the latter overwrites the previous, so you should do:
And you can't call it directly because it's protected. I see.
not the nicest solution, but yeah..
thanks for your input and time 👍
You are welcome
@Dennis Koch still like making a mixin for it: