0

I am using Facebook's Draft.js library to create a rich text box and I have a requirement to make the caret of the text box red. Is it possible?

I have read about the -webkit-text-fill-color property but it is making the typed text and the placeholder red instead of the caret.

Tarun Dugar
  • 8,921
  • 8
  • 42
  • 79

2 Answers2

4

This will make the caret red, and the text black, in webkit browsers:

.public-DraftEditor-content {  
  color: red;
  text-shadow: 0px 0px 0px #000;
  -webkit-text-fill-color: transparent;
}

Here's a fiddle showing it in action: https://jsfiddle.net/2atqzz5r/

Update: As of Chrome 57, you can use the new property caret-color:

.public-DraftEditor-content {  
  caret-color: red;
}

https://jsfiddle.net/yuk0fogn/

tobiasandersen
  • 8,480
  • 3
  • 28
  • 39
  • I actually think it works in the latest version of Firefox. Here's a list of all browsers supporting it: http://caniuse.com/#search=text-fill-color – tobiasandersen Jan 24 '17 at 10:44
0

Use caret-color:

div.class {
    caret-color : red;
}

Supported in 56% of browsers

Gibolt
  • 42,564
  • 15
  • 187
  • 127