--- name: rich-text description: "Software Mansion's best practices for rich text in React Native using react-native-enriched and react-native-enriched-markdown. Use when building rich text editors, formatted text inputs, Markdown renderers, or any feature requiring inline styling, mentions, links, structured text editing, or Markdown display. Trigger on: 'rich text editor', 'rich text input', 'text editor', 'react-native-enriched', 'react-native-enriched-markdown', 'EnrichedTextInput', 'EnrichedMarkdownText', 'formatted text input', 'WYSIWYG', 'mentions input', 'text formatting toolbar', 'markdown renderer', 'markdown display', 'render markdown', 'display markdown natively', 'LaTeX math', 'GFM tables', or any request to build rich text editing or Markdown rendering in React Native." --- # Rich Text in React Native Software Mansion's production patterns for rich text editing and Markdown rendering in React Native. There are two libraries that cover rich text use cases: | Library | Component | Purpose | |---------|-----------|---------| | `react-native-enriched` | `EnrichedTextInput` | Rich text **editing** (input) | | `react-native-enriched-markdown` | `EnrichedMarkdownText` | Markdown **rendering** (display) | Both libraries require the React Native New Architecture (Fabric) and support iOS and Android. ## Choosing the right library - **User needs to type/edit rich text** (bold, italic, mentions, links, inline images): use `react-native-enriched` - **App needs to display Markdown content** (chat messages, documentation, AI responses): use `react-native-enriched-markdown` - **Both editing and display**: use both libraries together ## react-native-enriched (Editor) `EnrichedTextInput` is a native, uncontrolled rich text input. It directly interacts with platform-specific components for performance, meaning it does not use React state for its value. ```bash npm install react-native-enriched ``` ### Basic usage ```tsx import { EnrichedTextInput } from 'react-native-enriched'; import type { EnrichedTextInputInstance, OnChangeStateEvent, } from 'react-native-enriched'; import { useState, useRef } from 'react'; import { View, Button, StyleSheet } from 'react-native'; export default function RichEditor() { const ref = useRef(null); const [stylesState, setStylesState] = useState(); return ( setStylesState(e.nativeEvent)} style={styles.input} />