Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS safari input caret color

Tags:

css

ios

safari

I have a small CSS issue with Safari on iPhone device. My search input is blue and when user focuses on it, caret is almost invisible:

Caret

In all desktop browsers, it has right color (white), even on desktop Safari. Any idea how to fix this and change caret color on iOS device?

Input styles:

input {
  background-color: $stateBlue;
  height: $navbarItemHeight;
  padding: 0 10px;
  vertical-align: bottom;
  color: $white;
  border-radius: $borderRadius;
  font-size: 1.1666666667em; // 16px
  -moz-appearance:none;
  -webkit-appearance:none;

  &::-webkit-input-placeholder {
    text-shadow: none;
    -webkit-text-fill-color: initial;
  }
}
like image 490
Pawel Avatar asked May 30 '16 14:05

Pawel


1 Answers

There is a W3C specification for this called caret-color which can be used like this:

input[type="text"].custom {
  caret-color: red;
}
<div>
  <label>default caret:</label>
  <input type="text"/>
</div>
<div>
  <label>custom red caret:</label>
  <input type="text" class="custom"/>
</div>

It's currently supported by Chrome (also on Android), Firefox, Opera and Safari (including iOS).

like image 189
Linus Caldwell Avatar answered Sep 23 '22 03:09

Linus Caldwell