jsdf / react-native-htmlview

A React Native component which renders HTML content as native views
ISC License
2.71k stars 467 forks source link

How to style text not wrapped in any tag #218

Open Noitidart opened 6 years ago

Noitidart commented 6 years ago

Sometimes my content is wrapped in a <p> other times its not. In the times that its plain text, how to style the body?

I tried using html and body but it doesnt work.

My code:

const textStyle = { color: CONFIG.blackish, fontSize: 14 }
const htmlStyles = StyleSheet.create({
    html: textStyle,
    body: textStyle,
    p: textStyle
})

render() {
    return <HTMLView value={body} stylesheet={htmlStyles} />
}
donni106 commented 6 years ago

Maybe you can wrap a div around your body and style divs?

return <HTMLView value={`<div>${body}</div>`} stylesheet={htmlStyles} />
const htmlStyles = StyleSheet.create({
    div: textStyle,
    p: textStyle
})
Noitidart commented 6 years ago

Oh yes true I can add a wrap. Is there no other way?