If true, focuses the input.
| Type | Default Value | Platform |
|---|---|---|
bool |
false |
Both |
Tells input to automatically capitalize certain characters.
characters: all characters.words: first letter of each word.sentences: first letter of each sentence.none: don't auto capitalize anything.
| Type | Default Value | Platform |
|---|---|---|
'none' | 'sentences' | 'words' | 'characters' |
'sentences' |
Both |
An array of custom items to display in the native text editing menu. Each item specifies a title, visibility flag, and a callback that fires when the item is tapped.
The onPress callback receives a single object argument with the following properties:
text- the currently selected text.selection- an object withstartandendindices of the current selection.styleState- the latestOnChangeStateEventpayload reflecting active styles at the time of the tap.
Item type:
interface ContextMenuItem {
text: string;
onPress: (args: {
text: string;
selection: { start: number; end: number };
styleState: OnChangeStateEvent;
}) => void;
visible?: boolean;
}textis the title displayed in the menu.onPressis the callback invoked when the item is tapped.visiblecontrols whether the item is shown. Defaults totrue.
| Type | Default Value | Platform |
|---|---|---|
ContextMenuItem[] |
[] | iOS |
Note
On iOS items appear in array order, before the system items (Copy/Paste/Cut). On Android, there is no guaranteed order and custom items may be displayed in a submenu, depending on the device manufacturer.
When provided it will set the color of the cursor (or "caret") in the component.
| Type | Default Value | Platform |
|---|---|---|
color |
system default | Android |
Provides an initial value for the input. If the string is a valid HTML output of the EnrichedTextInput component (or other HTML that the parser will accept), proper styles will be applied.
| Type | Default Value | Platform |
|---|---|---|
string |
- | Both |
If false, text is not editable.
| Type | Default Value | Platform |
|---|---|---|
bool |
true |
Both |
Note
Setting editable to false will disable all user interactions with the input.
However, some programmatic changes (like toggling styles or changing value imperatively) via ref methods will still work.
A prop for customizing styles appearances.
| Type | Default Value | Platform |
|---|---|---|
HtmlStyle |
default values from HtmlStyle |
Both |
The recognized mention indicators. Each item needs to be a 1 character long string.
| Type | Default Value | Platform |
|---|---|---|
array of string |
['@'] |
Both |
A custom regex pattern for detecting links in the input. If not provided, a default regex will be used.
With this approach you can customize what patterns should be recognized as links, for example you can make it so that only links starting with https:// are detected, or you can support custom schemes.
Keep in mind that not all JS regex features are supported, for example variable-width lookbehinds won't work.
| Type | Default Value | Platform |
|---|---|---|
RegExp |
default native platform regex | Both |
Tip
With this approach you can also disable link detection completely by providing a null value as the prop.
Callback that's called whenever the input loses focused (is blurred).
| Type | Platform |
|---|---|
() => void |
Both |
Callback that is called when input's HTML changes.
Payload interface:
interface OnChangeHtmlEvent {
value: string;
}valueis the new HTML.
| Type | Platform |
|---|---|
(event: NativeSyntheticEvent<OnChangeHtmlEvent>) => void |
Both |
Tip
Specifying onChangeHtml may have performance implications, especially with large documents, as it requires continuous HTML parsing.
If you only need the HTML content at specific moments (e.g., when saving), consider using the getHTML ref method instead.
When onChangeHtml is not provided, the component optimizes performance by avoiding unnecessary HTML parsing.
Callback that gets called anytime user makes some changes to a mention that is being edited.
Payload interface:
interface OnChangeMentionEvent {
indicator: string;
text: string;
}indicatoris the indicator of the currently edited mention.textcontains whole text that has been typed after the indicator.
| Type | Platform |
|---|---|
(event: OnChangeMentionEvent) => void |
Both |
Callback that is called each time user changes selection or moves the cursor in the input.
Payload interface:
interface OnChangeSelectionEvent {
start: Int32;
end: Int32;
text: string;
}startis the index of the selection's beginning.endis the first index after the selection's ending. For just a cursor in place (no selection),startequalsend.textis the input's text in the current selection.
| Type | Platform |
|---|---|
(event: NativeSyntheticEvent<OnChangeSelectionEvent>) => void |
Both |
Callback that gets called when any of the styles within the selection changes.
Payload interface:
interface OnChangeStateEvent {
bold: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
italic: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
underline: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
strikeThrough: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
inlineCode: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
h1: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
h2: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
h3: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
h4: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
h5: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
h6: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
codeBlock: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
blockQuote: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
orderedList: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
unorderedList: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
link: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
image: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
mention: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
checkboxList: {
isActive: boolean;
isConflicting: boolean;
isBlocking: boolean;
};
}isActiveindicates if the style is active within current selection.isBlockingindicates if the style is blocked by other currently active, meaning it can't be toggled.isConflictingindicates if the style is in conflict with other currently active styles, meaning toggling it will remove conflicting style.
| Type | Platform |
|---|---|
(event: NativeSyntheticEvent<OnChangeStateEvent>) => void |
Both |
Callback called when any text changes occur in the input.
Payload interface:
interface OnChangeTextEvent {
value: string;
}valueis the new text value of the input.
| Type | Platform |
|---|---|
(event: NativeSyntheticEvent<OnChangeTextEvent>) => void |
Both |
Tip
If you don't need the plain text value do not specify onChangeText, as it may have performance implications due to continuous text extraction.
Callback that is called when the user no longer edits a mention actively - has moved the cursor somewhere else or put a space and the cursor isn't within the edited mention.
indicatoris the indicator of the mention that was being edited.
| Type | Platform |
|---|---|
(indicator: string) => void |
Both |
Callback that's called whenever the input is focused.
| Type | Platform |
|---|---|
() => void |
Both |
Callback that gets called when either a new link has been added or the user has moved the cursor/selection to some link.
Payload interface contains all the useful link data:
interface OnLinkDetected {
text: string;
url: string;
start: Int32;
end: Int32;
}textis the link's displayed text.urlis the underlying link's URL.startis the starting index of the link.endis the first index after the ending index of the link.
| Type | Platform |
|---|---|
(event: OnLinkDetected) => void |
Both |
Callback called when mention has been detected - either a new mention has been added or the user has moved the cursor/selection to some mention.
Payload interface contains all the useful mention data:
interface OnMentionDetected {
text: string;
indicator: string;
attributes: Record<string, string>;
}textis the mention's displayed text.indicatoris the indicator of the mention.attributesare the additional user-defined attributes that are being stored with the mention.
| Type | Platform |
|---|---|
(event: OnMentionDetected) => void |
Both |
Callback that gets called whenever a mention editing starts (after placing the indicator).
indicatoris the indicator of the mention that begins editing.
| Type | Platform |
|---|---|
(indicator: string) => void |
Both |
Callback that is called when a key is pressed. See TextInput onKeyPress for more details.
export interface OnKeyPressEvent {
key: string;
}| Type | Platform |
|---|---|
(event: NativeSyntheticEvent<OnKeyPressEvent>) => void |
Both |
Callback invoked when the user pastes one or more images or GIFs into the input.
images- is an array of objects containing the details (URI, MIME type, and dimensions) for each pasted image/GIF.
export interface OnPasteImagesEvent {
images: {
uri: string;
type: string;
width: Float;
height: Float;
}[];
}| Type | Platform |
|---|---|
(event: NativeSyntheticEvent<OnPasteImagesEvent>) => void |
Both |
The placeholder text that is displayed in the input if nothing has been typed yet. Disappears when something is typed.
| Type | Default Value | Platform |
|---|---|---|
string |
'' |
Both |
Input placeholder's text color.
| Type | Default Value | Platform |
|---|---|---|
color |
input's color | Both |
A React ref that lets you call any ref methods on the input.
| Type | Default Value | Platform |
|---|---|---|
RefObject<EnrichedTextInputInstance | null> |
- | Both |
Color of the selection rectangle that gets drawn over the selected text. On iOS, the cursor (caret) also gets set to this color.
| Type | Default Value | Platform |
|---|---|---|
color |
system default | Both |
Accepts most ViewStyle props, but keep in mind that some of them might not be supported.
Additionally following TextStyle props are supported
- color
- fontFamily
- fontSize
- fontWeight
- lineHeight
- fontStyle only on Android
| Type | Default Value | Platform |
|---|---|---|
View Style | Text Style |
- | Both |
The input inherits ViewProps, but keep in mind that some of the props may not be supported.
If true, Android will use experimental synchronous events. This will prevent from input flickering when updating component size. However, this is an experimental feature, which has not been thoroughly tested. We may decide to enable it by default in a future release.
| Type | Default Value | Platform |
|---|---|---|
bool |
false |
Android |
If true, external HTML pasted/inserted into the input (e.g. from Google Docs, Word, or web pages) will be normalized into the canonical tag subset that the enriched parser understands. However, this is an experimental feature, which has not been thoroughly tested. We may decide to enable it by default in a future release.
| Type | Default Value | Platform |
|---|---|---|
bool |
false |
Both |
All the methods should be called on the input's ref.
blur: () => void;Blurs the input.
focus: () => void;Focuses the input.
getHTML: () => Promise<string>;Returns a Promise that resolves with the current HTML content of the input. This is useful when you need to get the HTML on-demand (e.g., when saving) without the performance overhead of continuous HTML parsing via onChangeHtml.
setImage: (src: string, width: number, height: number) => void;Sets the inline image at the current selection.
src: string- absolute path to a file or remote image address.width: number- width of the image.height: number- height of the image.
Note
It's developer responsibility to provide proper width and height, which may require calculating aspect ratio. Also, keep in mind that in case of providing incorrect image source, static placeholder will be displayed. We may consider adding automatic image size detection and improved error handling in future releases.
setLink: (
start: number,
end: number,
text: string,
url: string
) => void;Sets the link at the given place with a given displayed text and URL. Link will replace any text if there was some between start and end indexes. Setting a link with start equal to end will just insert it in place.
start: number- the starting index where the link should be.end: number- first index behind the new link's ending index.text: string- displayed text of the link.url: string- URL of the link.
removeLink: (start: number, end: number) => void;Removes link styling from any links found within the given range. The text content is preserved, only the link attributes are stripped. Out-of-bounds values are clamped to valid range.
start: number- the starting index of the range to remove links from.end: number- first index behind the range's ending index.
setMention: (
indicator: string,
text: string,
attributes?: Record<string, string>
) => void;Sets the currently edited mention with a given indicator, displayed text and custom attributes.
indicator: string- the indicator of the set mention.text: string- the text that should be displayed for the mention. Anything the user typed gets replaced by that text. The mention indicator isn't added to that text.attributes?: Record<string, string>- additional, custom attributes for the mention that can be passed as a TypeScript record. They are properly preserved through parsing from and to the HTML format.
setValue: (value: string) => void;Sets the input's value.
value: string- value to set, it can either bereact-native-enrichedsupported HTML string or raw text.
setSelection: (start: number, end: number) => void;Sets the selection at the given indexes.
start: number- starting index of the selection.end: number- first index after the selection's ending index. For just a cursor in place (no selection),startequalsend.
startMention: (indicator: string) => void;Starts a mention with the given indicator. It gets put at the cursor/selection.
indicator: string- the indicator that starts the new mention.
toggleBlockQuote: () => void;Toggles blockquote style at the current selection.
toggleBold: () => void;Toggles bold formatting at the current selection.
toggleCodeBlock: () => void;Toggles codeblock formatting at the current selection.
toggleH1: () => void;Toggles heading 1 (H1) style at the current selection.
toggleH2: () => void;Toggles heading 2 (H2) style at the current selection.
toggleH3: () => void;Toggles heading 3 (H3) style at the current selection.
toggleH4: () => void;Toggles heading 4 (H4) style at the current selection.
toggleH5: () => void;Toggles heading 5 (H5) style at the current selection.
toggleH6: () => void;Toggles heading 6 (H6) style at the current selection.
toggleInlineCode: () => void;Applies inline code formatting to the current selection.
toggleItalic: () => void;Toggles italic formatting at the current selection.
toggleOrderedList: () => void;Converts current selection into an ordered list.
toggleStrikeThrough: () => void;Applies strikethrough formatting to the current selection.
toggleUnderline: () => void;Applies underline formatting to the current selection.
toggleUnorderedList: () => void;Converts current selection into an unordered list.
toggleCheckboxList: (checked: boolean) => void;Converts current selection into an unordered list with checkboxes as items. Each checkbox can be either checked or unchecked. User can later toggle each checkbox individually by tapping on it.
checked: boolean- defines whether the checkboxes should be checked or unchecked by default.
Allows customizing HTML styles.
interface HtmlStyle {
h1?: {
fontSize?: number;
bold?: boolean;
};
h2?: {
fontSize?: number;
bold?: boolean;
};
h3?: {
fontSize?: number;
bold?: boolean;
};
h4?: {
fontSize?: number;
bold?: boolean;
};
h5?: {
fontSize?: number;
bold?: boolean;
};
h6?: {
fontSize?: number;
bold?: boolean;
};
blockquote?: {
borderColor?: ColorValue;
borderWidth?: number;
gapWidth?: number;
color?: ColorValue;
};
codeblock?: {
color?: ColorValue;
borderRadius?: number;
backgroundColor?: ColorValue;
};
code?: {
color?: ColorValue;
backgroundColor?: ColorValue;
};
a?: {
color?: ColorValue;
textDecorationLine?: 'underline' | 'none';
};
mention?: Record<string, MentionStyleProperties> | MentionStyleProperties;
ol?: {
gapWidth?: number;
marginLeft?: number;
markerFontWeight?: TextStyle['fontWeight'];
markerColor?: ColorValue;
};
ul?: {
bulletColor?: ColorValue;
bulletSize?: number;
marginLeft?: number;
gapWidth?: number;
};
ulCheckbox?: {
boxColor?: ColorValue;
boxSize?: number;
marginLeft?: number;
gapWidth?: number;
};
}
interface MentionStyleProperties {
color?: ColorValue;
backgroundColor?: ColorValue;
textDecorationLine?: 'underline' | 'none';
}fontSizeis the size of the heading's font. Defaults to32forH1,24forH2,20forH3,16forH4,14forH5,12forH6.bolddefines whether the heading should be bolded, defaults tofalse.
borderColordefines the color of the rectangular border drawn to the left of blockquote text. Takes color value, defaults todarkgray.borderWidthsets the width of the said border, defaults to4.gapWidthsets the width of the gap between the border and the blockquote text, defaults to16.colordefines the color of blockquote's text. Takes color value, if not set makes the blockquote text the same color as the input's color prop.
colordefines the color of codeblock text, takes color value and defaults toblack.borderRadiussets the radius of codeblock's border, defaults to 8.backgroundColoris the codeblock's background color, takes color value and defaults todarkgray.
colordefines the color of inline code's text, takes color value and defaults tored.backgroundColoris the inline code's background color, takes color value and defaults todarkgray.
colordefines the color of link's text, takes color value and defaults toblue.textDecorationLinedecides if the links are underlined or not, takes eitherunderlineornoneand defaults tounderline
If only a single config is given, the style applies to all mention types. You can also set a different config for each mentionIndicator that has been defined, then the prop should be a record with indicators as a keys and configs as their values.
colordefines the color of mention's text, takes color value and defaults toblue.backgroundColoris the mention's background color, takes color value and defaults toyellow.textDecorationLinedecides if the mentions are underlined or not, takes eitherunderlineornoneand defaults tounderline.
By marker, we mean the number that denotes next lines of the list.
gapWidthsets the gap between the marker and the list item's text, defaults to16.marginLeftsets the margin to the left of the marker (between the marker and input's left edge), defaults to16.markerFontWeightdefines the font weight of the marker, takes a fontWeight value and if not set, defaults to the same font weight as input's fontWeight prop.markerColorsets the text color of the marker, takes color value and if not set, defaults to the same color as input's color prop.
By bullet, we mean the dot that begins each line of the list.
bulletColordefines the color of the bullet, takes color value and defaults toblack.bulletSizesets both the height and the width of the bullet, defaults to8.marginLeftis the margin to the left of the bullet (between the bullet and input's left edge), defaults to16.gapWidthsets the gap between the bullet and the list item's text, defaults to16.
Allows using unordered list with checkboxes instead of bullets.
boxColordefines the color of the checkbox, takes color value and defaults toblue.boxSizesets both the height and the width of the checkbox, defaults to24.marginLeftis the margin to the left of the checkbox (between the checkbox and input's left edge), defaults to16.gapWidthsets the gap between the checkbox and the list item's text, defaults to16.