skills/react-native-best-practices/references/rich-text/SKILL.md
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.
npx skillsauth add software-mansion-labs/skills rich-textInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
react-native-enrichedreact-native-enriched-markdownEnrichedTextInput 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.
npm install react-native-enriched
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<EnrichedTextInputInstance>(null);
const [stylesState, setStylesState] = useState<OnChangeStateEvent | null>();
return (
<View style={styles.container}>
<EnrichedTextInput
ref={ref}
onChangeState={(e) => setStylesState(e.nativeEvent)}
style={styles.input}
/>
<Button
title={stylesState?.bold.isActive ? 'Unbold' : 'Bold'}
color={stylesState?.bold.isActive ? 'green' : 'gray'}
onPress={() => ref.current?.toggleBold()}
/>
</View>
);
}
Toggling styles via ref: All formatting is applied imperatively through the ref. Call ref.current?.toggleBold(), ref.current?.toggleItalic(), etc.
Style detection via onChangeState: The onChangeState callback fires whenever the style state changes (e.g., cursor moves into bold text). Each style reports three properties:
isActive: The style is applied at the current selection (highlight the toolbar button)isBlocking: The style is blocked by another active style (disable the toolbar button)isConflicting: The style conflicts with another active style (toggling it removes the conflicting style)Inline vs paragraph styles:
HTML output: Get HTML via ref.current?.getHTML() (on-demand, returns a Promise) or the onChangeHtml callback (continuous, has performance cost for large documents). Prefer getHTML() when you only need HTML at save time.
Setting content: Use defaultValue prop for initial HTML content, or ref.current?.setValue(html) to update imperatively.
The OnChangeStateEvent key column shows the exact property name on the event object returned by onChangeState. Use these keys when reading style state (e.g. stylesState.strikeThrough.isActive). Note that casing varies (e.g. strikeThrough with capital T, inlineCode with capital C).
| Style | Toggle method | OnChangeStateEvent key | Type |
|-------|--------------|--------------------------|------|
| Bold | toggleBold() | bold | Inline |
| Italic | toggleItalic() | italic | Inline |
| Underline | toggleUnderline() | underline | Inline |
| Strikethrough | toggleStrikeThrough() | strikeThrough | Inline |
| Inline code | toggleInlineCode() | inlineCode | Inline |
| H1 | toggleH1() | h1 | Paragraph |
| H2 | toggleH2() | h2 | Paragraph |
| H3 | toggleH3() | h3 | Paragraph |
| H4 | toggleH4() | h4 | Paragraph |
| H5 | toggleH5() | h5 | Paragraph |
| H6 | toggleH6() | h6 | Paragraph |
| Code block | toggleCodeBlock() | codeBlock | Paragraph |
| Block quote | toggleBlockQuote() | blockQuote | Paragraph |
| Ordered list | toggleOrderedList() | orderedList | Paragraph |
| Unordered list | toggleUnorderedList() | unorderedList | Paragraph |
| Checkbox list | toggleCheckboxList(checked) | checkboxList | Paragraph |
Links are detected automatically (customizable via linkRegex prop) or applied manually:
// Set link on selected text
ref.current?.setLink(selection.start, selection.end, selectedText, url);
// Remove link
ref.current?.removeLink(start, end);
Use onChangeSelection to get selection position and onLinkDetected to detect when the cursor is near a link.
Mentions support custom indicators (default: @). Set custom indicators via the mentionIndicators prop.
<EnrichedTextInput
ref={ref}
mentionIndicators={['@', '#']}
onStartMention={(indicator) => { /* show picker */ }}
onChangeMention={({ indicator, text }) => { /* filter list */ }}
onEndMention={(indicator) => { /* hide picker */ }}
/>
// Complete the mention when user selects from picker
ref.current?.setMention('@', 'John Doe', { userId: '123' });
ref.current?.setImage(imageUri, width, height);
Images are inserted at the cursor position (or replace selected text) and affect line height. You are responsible for providing correct dimensions.
For the full API (all props, ref methods, events, HtmlStyle customization, context menu items), webfetch the react-native-enriched README.
EnrichedMarkdownText renders Markdown as fully native text (no WebView). It uses md4c for high-performance CommonMark-compliant parsing.
npm install react-native-enriched-markdown
import { EnrichedMarkdownText } from 'react-native-enriched-markdown';
import { Linking } from 'react-native';
const markdown = `
# Welcome
This is **bold**, *italic*, and [a link](https://reactnative.dev).
- List item one
- List item two
`;
export default function MarkdownDisplay() {
return (
<EnrichedMarkdownText
markdown={markdown}
onLinkPress={({ url }) => Linking.openURL(url)}
/>
);
}
| Flavor | Features | Layout |
|--------|----------|--------|
| commonmark (default) | All CommonMark elements, inline math ($...$) | Single TextView |
| github | CommonMark + GFM tables, task lists, block math ($$...$$) | Segmented layout (separate TextViews + table views) |
<EnrichedMarkdownText
flavor="github"
markdown={markdown}
onLinkPress={({ url }) => Linking.openURL(url)}
/>
Tables require flavor="github" and support column alignment, rich text in cells, horizontal scrolling, header styling, alternating row colors, and a long-press context menu.
<EnrichedMarkdownText
flavor="github"
markdown={tableMarkdown}
markdownStyle={{
table: {
fontSize: 14,
borderColor: '#E5E7EB',
borderRadius: 8,
headerBackgroundColor: '#F3F4F6',
cellPaddingHorizontal: 12,
cellPaddingVertical: 8,
},
}}
/>
Task lists require flavor="github". Handle checkbox taps with onTaskListItemPress:
<EnrichedMarkdownText
flavor="github"
markdown={`- [x] Done\n- [ ] Todo`}
onTaskListItemPress={({ index, checked, text }) => {
console.log(`Task ${index}: ${checked ? 'checked' : 'unchecked'}`);
}}
/>
$...$): works in both flavors$$...$$): requires flavor="github", must be on its own lineUse String.raw or double backslashes for LaTeX commands in JS strings.
Disable math to reduce bundle size (iosMath ~2.5 MB on iOS):
<EnrichedMarkdownText md4cFlags={{ latexMath: false }} markdown="..." />
Use the markdownStyle prop. Memoize it with useMemo to avoid re-renders:
import type { MarkdownStyle } from 'react-native-enriched-markdown';
const markdownStyle: MarkdownStyle = useMemo(() => ({
paragraph: { fontSize: 16, color: '#333', lineHeight: 24 },
h1: { fontSize: 32, fontWeight: 'bold', marginBottom: 16 },
code: { color: '#E91E63', backgroundColor: '#F5F5F5' },
codeBlock: { backgroundColor: '#1E1E1E', color: '#D4D4D4', padding: 16, borderRadius: 8 },
link: { color: '#007AFF', underline: true },
blockquote: { borderColor: '#007AFF', backgroundColor: '#F0F8FF' },
}), []);
Inline elements inherit typography from their parent block (fontSize, fontFamily, color), then add their own styling on top.
<EnrichedMarkdownText
markdown={content}
onLinkPress={({ url }) => Linking.openURL(url)}
onLinkLongPress={({ url }) => showShareSheet(url)}
// On iOS, providing onLinkLongPress disables the system link preview
/>
selectable prop). Smart Copy provides plain text, Markdown, HTML, RTF, and RTFD on iOS.I18nManager.forceRTL(true) before rendering.md4cFlags={{ underline: true }} makes _text_ render as underline instead of italic.For detailed API documentation, webfetch the relevant page from the upstream docs:
fontSize as the input's fontSizeflavor="github" segments text into separate TextViews, so text selection cannot span across segmentsdevelopment
Use when the user mentions migrating deep links, switching away from Branch or AppsFlyer, replacing their deep linking SDK, setting up Detour deep linking for the first time, or asks how Branch/AppsFlyer concepts map to Detour. Covers the complete migration end to end - Detour Dashboard configuration, Universal Links and App Links setup, SDK swap with code examples, and analytics migration. Works across Android, iOS, React Native, and Flutter.
development
Complete onboarding guide for developers who are new to Detour, the open-source deferred deep linking SDK by Software Mansion. Use this skill whenever a user asks what Detour is, how to get started with Detour, how to set up deep linking with Detour, how to install the Detour SDK, how to configure the Detour dashboard, or how deferred deep linking works. Also use it when the user has no prior deep linking setup and wants to add deep links to their app. Covers everything from zero to production: account setup, dashboard configuration, Universal Links and App Links, platform SDK integration for React Native, iOS, Android, and Flutter, analytics, and architecture.
tools
React Native / Expo SDK for Fishjam — video/audio streaming on iOS and Android. Use when writing a React Native or Expo app that calls Fishjam, configures the Fishjam Expo plugin, sets up permissions, runs background streaming, integrates CallKit, or renders RTCView. Trigger on: '@fishjam-cloud/react-native-client', 'fishjam expo plugin', 'FishjamProvider mobile', 'useCameraPermissions', 'useMicrophonePermissions', 'useForegroundService', 'useCallKit', 'useCallKitEvent', 'useCallKitService', 'RTCView', 'RTCPIPView', 'ScreenCapturePickerView', 'startPIP', 'stopPIP', 'AudioDeviceType', 'useAudioOutput', '@fishjam-cloud/react-native-webrtc', 'fishjam react native', 'expo fishjam', 'fishjam ios', 'fishjam android', 'broadcast extension'. Re-exports @fishjam-cloud/react-client hooks plus mobile-only: permissions, foreground service, iOS broadcast extension, audio routing, CallKit, Expo config plugin.
tools
Browser-only React SDK for Fishjam — joining rooms, capturing camera/microphone/screen, displaying peers, and acting as a livestream streamer or viewer in a React web app. Use whenever the user is writing a React app in a browser that calls Fishjam APIs, sets up FishjamProvider, or uses any Fishjam React hook. Trigger on: '@fishjam-cloud/react-client', 'FishjamProvider', 'useConnection', 'useCamera', 'useMicrophone', 'useScreenShare', 'usePeers', 'useDataChannel', 'useVAD', 'useLivestreamStreamer', 'useLivestreamViewer', 'useCustomSource', 'useInitializeDevices', 'useUpdatePeerMetadata', 'useSandbox', 'PeerWithTracks', 'joinRoom', 'peerToken', 'fishjamId', 'fishjam react', '@fishjam-cloud/ts-client', 'FishjamClient ts-client'. Covers the provider, the full hook catalog, simulcast configuration, custom sources, data channels, VAD, livestream WHEP playback, device persistence, and reconnection. Briefly notes when to drop down to @fishjam-cloud/ts-client for non-React or worker contexts.