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 |
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 |
Callback that's called whenever the input loses focused (is blurred).
| Type | Default Value | Platform |
|---|---|---|
() => void |
- | Both |
Callback that is called when input's HTML changes.
Payload interface:
interface OnChangeHtmlEvent {
value: string;
}valueis the new HTML.
| Type | Default Value | 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 | Default Value | 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 | Default Value | Platform |
|---|---|---|
(event: NativeSyntheticEvent<OnChangeSelectionEvent>) => void |
- | Both |
Callback that gets called when any of the styles within the selection changes.
Payload has a bool flag for each style:
interface OnChangeStateEvent {
isBold: boolean;
isItalic: boolean;
isUnderline: boolean;
isStrikeThrough: boolean;
isInlineCode: boolean;
isH1: boolean;
isH2: boolean;
isH3: boolean;
isCodeBlock: boolean;
isBlockQuote: boolean;
isOrderedList: boolean;
isUnorderedList: boolean;
isLink: boolean;
isImage: boolean;
isMention: boolean;
}| Type | Default Value | 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 | Default Value | Platform |
|---|---|---|
(event: NativeSyntheticEvent<OnChangeTextEvent>) => void |
- | Both |
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 | Default Value | Platform |
|---|---|---|
(indicator: string) => void |
- | Both |
Callback that's called whenever the input is focused.
| Type | Default Value | 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 | Default Value | 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 | Default Value | 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 | Default Value | Platform |
|---|---|---|
(indicator: string) => 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
- 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 |
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.
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.
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.
Allows customizing HTML styles.
interface HtmlStyle {
h1?: {
fontSize?: number;
bold?: boolean;
};
h2?: {
fontSize?: number;
bold?: boolean;
};
h3?: {
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;
};
}
interface MentionStyleProperties {
color?: ColorValue;
backgroundColor?: ColorValue;
textDecorationLine?: 'underline' | 'none';
}fontSizeis the size of the heading's font, defaults to32/24/20for h1/h2/h3.bolddefines whether the heading should be bolded, defaults tofalse.
Note
On iOS, the headings cannot have same fontSize as the component's fontSize. Doing so results in unexpected behavior.
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.