Skip to main content

Props

PropTypeDescription
htmlstringThe HTML source to render.
baseStyleResolvedStyleRoot style. Inherited text props cascade to all content; box props (background, padding, and so on) style the root container.
stylesheetstringA CSS stylesheet with real selectors: type, class, id, descendant, child. See Styling and cascade.
tagsStylesRecord<tag, StyleInput>Per-tag style override, for example { h1: {...} }. body is special: it styles the document root even when the HTML is a fragment with no <body> tag.
classesStylesRecord<class, StyleInput>Style by class attribute.
idsStylesRecord<id, StyleInput>Style by id attribute.
customRenderersRecord<tag, CustomRenderer>Replace or wrap the renderer for any tag.
customHTMLElementModelsRecord<tag, HTMLElementModel>Define new tags with custom block or inline semantics and default styles.
renderersPropsRecord<tag, Record<string, unknown>>Per-renderer config. Built-in consumers: ol.startIndex, ul.markerTextStyle and ol.markerTextStyle, img.initialDimensions, and details (initialOpen, markerTextStyle, onToggle).
contentWidthnumberMaximum render width. Images wider than this scale down proportionally.
transformDom(dom: DomNode[]) => DomNode[]Runs after parsing, before the render tree is built. Use it for sanitization or tag rewrites.
onLinkPress(href, attribs) => voidOverrides the default Linking.openURL link handler.
ignoredDomTagsstring[]Tags to drop during parsing, subtree included. Merged with the built-in defaults: head, title, style, script, link, meta, base.
ignoredStylesstring[]CSS properties to drop. Accepts kebab-case (background-color) or camelCase (backgroundColor).
defaultTextPropsTextPropsSpread onto every <Text>.
defaultViewPropsViewPropsSpread onto every <View>.
textSelectablebooleanShortcut for defaultTextProps.selectable = true.

StyleInput

StyleInput is ResolvedStyle | string. Every style map accepts either a React Native style object or a CSS declaration string:

tagsStyles={{
h1: { color: 'red', fontSize: 24 },
h2: 'color: blue; font-size: 20px',
}}

Exported types

The package exports the types used above so you can annotate your own code, including CustomRenderer, HTMLElementModel, OnLinkPress, StyleInput, TransformDom and DomNode.