Skip to content

Instantly share code, notes, and snippets.

@JoeKeikun
Last active June 7, 2022 12:08
Show Gist options
  • Save JoeKeikun/72718f5faaf518304024 to your computer and use it in GitHub Desktop.
Save JoeKeikun/72718f5faaf518304024 to your computer and use it in GitHub Desktop.
How to change <input> input cursor color by css (webkit)
When I developed an app for ios by phonegap, I had a trouble in changing the <input> input cursor color.
but now, there is a solution for it:
---------------
<style>
input {
color: rgb(60, 0, 248); /* change [input cursor color] by this*/
text-shadow: 0px 0px 0px #D60B0B; /* change [input font] by this*/
-webkit-text-fill-color: transparent;
}
</style>
---------------
this will change placeholder's color too. If we also need to change placeholder's color after this, we can use this:
---------------
<style>
input::-webkit-input-placeholder{
color: rgb(60, 0, 248); /* change [placeholder color] by this*/
text-shadow: none;
-webkit-text-fill-color: initial;
}
</style>
---------------
@sstur
Copy link

sstur commented Jun 16, 2015

Awesome!

@vamsikaja
Copy link

This is not working for me. I tried adding the same styles it is working in Chrome and safari of OSX but not in iOS.

@liamsheppard
Copy link

This is great, cheers!

Copy link

ghost commented May 20, 2016

wooot...
awesome solution saved me from writing yet another javascript :D

@harrypujols
Copy link

Best solution I've found so far 👏

@venkatvb
Copy link

Someone have a idea how to remove the blinking effect of caret ?

@lichenbuliren
Copy link

it's so cool, thanks a lot!

@rubencodes
Copy link

Awesome! Would like to see what browser support there is for this. I think -webkit-text-fill-color is the limiting factor.

@haideralishah
Copy link

Not working.

@toddgower-hiatus
Copy link

Not working for me in iOS Safari

Copy link

ghost commented Jun 8, 2017

Not working in iOS safari

@Apollo-zz
Copy link

Not working in IE T.T

@Gibolt
Copy link

Gibolt commented Aug 13, 2017

Use caret-color instead!

input {
caret-color : rgb(60, 0, 248);
}

@khatrinitesh
Copy link

Nice code. thanks for the tip.

@khatrinitesh
Copy link

please let me know how to css use only on iphone caret-color:transparent;

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