Skip to main content

Props

CodeEditor takes every React Native ViewProps plus the props below. style sizes the editor like any other view. Style padding is ignored, contentInsets is the padding instead. The callbacks are on the events page.

Document​

PropTypeDefaultNotes
initialValuestring''Sets the initial text of the editor. It is read once, so use setText() to replace the document later.
languagestringundefinedThe id of an installed language package. Without the package the editor shows plain text.
readOnlybooleanfalseMakes the editor read only: no keyboard, and the toolbar methods that type or delete do nothing. Selection, copy and search still work.

Appearance​

PropTypeDefaultNotes
themeThemegithubLightThe colors. Hoist the object, it is compared by identity. See theme tokens.
fontFamilystringmonospace on Android, Menlo on iOSThe font, by name. Fonts linked with react-native-asset or expo-font resolve by name.
fontSizenumber14In dp on Android and points on iOS.
lineHeightnumber1.4A multiplier of the font size. The row height is round(fontSize * lineHeight).
lineNumbersbooleantrueShows the line number gutter.
softWrapbooleanfalseWraps long lines. Off means horizontal scrolling.
highlightActiveLinebooleantruePaints the line the caret is on.
matchBracketsbooleantruePaints the bracket pair at the caret. Brackets inside strings and comments are skipped.
placeholderstringundefinedText drawn while the document is empty.

Editing​

PropTypeDefaultNotes
tabSizenumber4The width of one indentation level.
insertSpacesbooleantrueIndents with spaces. Off indents with tabs.
autoIndentbooleantrueA newline keeps the indentation of the line above and adds a level inside an open bracket.
autoCloseBracketsbooleantrueCloses pairs as you type, skips over a closer you type yourself, wraps a selection, and removes an empty pair on Backspace.
suggestionsSuggestions'off'What the keyboard offers: off asks for none, forceOff also kills composition on most Android keyboards, on allows autocorrect. On iOS forceOff is the same as off.
autoFocusbooleanfalseFocuses the editor and shows the keyboard once the view is attached.

Scrolling and keyboard​

PropTypeDefaultNotes
scrollEnabledbooleantrueOff lets a parent ScrollView scroll through the editor.
contentInsetsContentInsetsall 0The padding inside the scrollable area, in dp on Android and points on iOS. A bottom inset keeps the caret above a toolbar.
avoidKeyboardbooleanfalseAdds the keyboard overlap to the bottom inset on every frame of the keyboard animation. See the keyboard guide.