I want to change all text's color of a html which was rendered by react-native-render-html
Loading
I want to change all text's color of a html which was rendered by react-native-render-html
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jayraj ChhayaPosted Nov 28, 2023, 10:00 AM
To change the text color of an HTML rendered by
react-native-render-html, you can make use of therenderersPropsprop provided by the library. This prop allows you to customize the rendering of specific HTML elements.we define a custom text renderer component
CustomTextRendererthat wraps the text with acomponent and applies a red color style. We then pass this custom renderer to therenderersPropsprop for theandHTML elements.Chandru TSPosted Dec 4, 2023, 5:55 AM
source={{html: source}}
contentWidth={width}
baseStyle = {baseStyle}
/>
const baseStyle = {
color: 'black'
}
This works for all the tags commonly