Skip to content

API

PropTypeDescription
source{ html: string }The HTML to render. Required.
baseStyleRNStyleRoot styles, inherited down (e.g. font size/color).
tagStylesRecord<string, RNStyle>Per-tag styles, keyed by tag name.
classStylesRecord<string, RNStyle>Per-class styles, keyed by class name.
renderersRecord<string, Renderer>Override/add a renderer for any tag.
fontsFontMapPer-family/weight/style font-file map.
onLinkPress(href: string) => voidCalled when an <a> is pressed.
styleStyleProp<ViewStyle>Style for the outer container View.
  • RichText — the component.
  • defaultRenderers — the built-in tag→renderer map.
  • splitStyle(style) — partition an RNStyle into { text, view } props.
  • resolveFont(textStyle, fonts) — apply the fonts map to a resolved text style.
  • RichTextContext, useRichTextContext — the renderer context (registry, fonts, onLinkPress).
  • RichTextProps — the props above.
  • Renderer = ComponentType<RendererProps>
  • RendererProps = { node: RenderNode; children?: ReactNode }
  • FontMap = Record<string, Record<string, FontFaces>>, FontFaces = { normal?: string; italic?: string }
  • RenderNode — a node in the styled render tree (block / inline / text / table / …).
  • RNStyle — a curated subset of RN TextStyle & ViewStyle.