react-native-html5
html, html5 parser for react-native
Install
npm install react-native-html5
Usage
import Html5 from 'react-native-html5';
...
rawHtml={rawHtml}
styleSheet={styleSheet}
externalStyleSheet={externalStyleSheet}
/>
options
rawHtml
HTML Text
styleSheet
optional, styles
externalStyleSheet
optional, external styles, textIndent for
supported
Example
import React, { Component } from 'react';
import {
Text,
View,
StyleSheet,
} from 'react-native';
import Html5 from 'react-native-html5';
const rawHtml = `
h1. heading
h2. heading
h3. heading
h4. heading
h5. heading
h6. heading
<p> is a paragraph
<image> rendered as an image
<mark> renderd as highlight text
<del> or <s> rendered as deleted text
<u> or <ins> rendered as underlined text
<small> rendered as small text
<strong> or <b> rendered as bold text
<em> or <i> rendered as italicized text
<blockquote> rendered as a blockquote
<code> rendered as code
and other most of html tags supported.
`;
const styleSheet = {
a: {
color: '#00f',
}
};
const externalStyleSheet = {
p: {
textIndent: 0,
},
};
class ReactNativeHtml5Test extends Component {
render() {
return (
rawHtml={rawHtml}
styleSheet={styleSheet}
externalStyleSheet={externalStyleSheet}
/>
);
}
}
const styles = StyleSheet.create({
container: {
marginTop: 40,
padding: 20,
},
});