react-contenteditable icon indicating copy to clipboard operation
react-contenteditable copied to clipboard

how to set custom style in html

Open callmeguaishu opened this issue 3 years ago • 1 comments

const text = useRef('<p style={{color:'red'}}>123</p>'); const handleChange = evt => { text.current = evt.target.value; }; const handleBlur = () => { console.log(text.current); }; return <ContentEditable html={text.current} onBlur={handleBlur} onChange={handleChange} />

when I try to set custom style for html content, the 'style={{color:'red'}}' don't work, is that a bug ? what should I do?

callmeguaishu avatar Jan 17 '23 06:01 callmeguaishu

Hi, you must write HTML tag because render with dangerouslySetInnerHTML. const text = <p style='color:red'>123</p>

alikhani-dev avatar Mar 19 '23 07:03 alikhani-dev