Code editing and syntax highlighting for React Native apps - 25+ programming languages, code blocks, editable code input.
- ✅ 25+ Programming Languages - TypeScript, JavaScript, Python, Java, C#, C++, Swift, Kotlin, Go, Rust, PHP, Ruby, HTML, CSS, SCSS, JSON, XML, YAML, Markdown, SQL, Bash, Shell, Dockerfile, Plain Text
- ✅ CodeBlock Component - Read-only code display with syntax highlighting
- ✅ CodeInput Component - Editable code input with line numbers
- ✅ Language Detection - Auto-detect language from file extension
- ✅ Code Statistics - Line count, character count, file size
- ✅ Code Validation - Validate code length and snippet data
- ✅ Copy to Clipboard - One-click code copying
- ✅ Line Numbers - Optional line number display
- ✅ Type-Safe - Full TypeScript support
npm install @umituz/react-native-code-editornpm install @umituz/react-native-design-system-theme @umituz/react-native-icon @umituz/react-native-clipboard @umituz/react-native-toastimport { CodeBlock } from '@umituz/react-native-code-editor';
<CodeBlock
code={snippetCode}
language="typescript"
showLineNumbers
showCopyButton
/>import { CodeInput } from '@umituz/react-native-code-editor';
const [code, setCode] = useState('');
<CodeInput
value={code}
onChangeText={setCode}
language="javascript"
placeholder="Enter your code..."
showLineNumbers
/>import { CodeEditorUtils } from '@umituz/react-native-code-editor';
// Detect language from filename
const lang = CodeEditorUtils.detectLanguage('App.tsx'); // 'typescript'
// Count lines
const lines = CodeEditorUtils.countLines(code);
// Validate code length
const valid = CodeEditorUtils.isValidLength(code);
// Get preview
const preview = CodeEditorUtils.getCodePreview(code, 5);
// Format file size
const size = CodeEditorUtils.formatFileSize(1024); // "1.0 KB"
// Get language info
const name = CodeEditorUtils.getLanguageName('typescript'); // "TypeScript"
const icon = CodeEditorUtils.getLanguageIcon('typescript'); // "FileCode"
const ext = CodeEditorUtils.getFileExtension('typescript'); // ".ts"import { CodeEditorUtils, type CodeSnippet } from '@umituz/react-native-code-editor';
// Generate snippet ID
const id = CodeEditorUtils.generateSnippetId();
// Validate snippet
const validation = CodeEditorUtils.validateSnippet({
title: 'My Snippet',
code: 'console.log("Hello");',
language: 'javascript',
});
if (validation.valid) {
// Save snippet
} else {
console.error(validation.errors);
}Read-only code display component.
Props:
code: string- Code to displaylanguage?: ProgrammingLanguage- Programming language (default: 'plaintext')showLineNumbers?: boolean- Show line numbers (default: true)maxHeight?: number- Maximum height (default: 400)showCopyButton?: boolean- Show copy button (default: true)style?: ViewStyle- Custom container style
Editable code input component.
Props:
value: string- Code valueonChangeText: (text: string) => void- Change handlerlanguage?: ProgrammingLanguage- Programming language (default: 'plaintext')placeholder?: string- Placeholder textshowLineNumbers?: boolean- Show line numbers (default: true)minHeight?: number- Minimum height (default: 200)maxHeight?: number- Maximum height (default: 600)editable?: boolean- Editable state (default: true)style?: ViewStyle- Custom container style
Utility class for code operations.
Methods:
detectLanguage(filename: string): ProgrammingLanguage- Detect language from filenameformatForDisplay(code: string, maxLength?: number): string- Format code for displaycountLines(code: string): number- Count lines in codecountCharacters(code: string): number- Count charactersisValidLength(code: string): boolean- Validate code lengthgetLanguageIcon(language: ProgrammingLanguage): string- Get language icongetLanguageName(language: ProgrammingLanguage): string- Get language display namegetFileExtension(language: ProgrammingLanguage): string- Get file extensiongetCodePreview(code: string, lines?: number): string- Get code previewformatFileSize(bytes: number): string- Format file sizegenerateSnippetId(): string- Generate snippet IDvalidateSnippet(snippet: Partial<CodeSnippet>): { valid: boolean; errors: string[] }- Validate snippet
- TypeScript (
.ts,.tsx) - JavaScript (
.js,.jsx) - Python (
.py) - Java (
.java) - C# (
.cs) - C++ (
.cpp,.cc) - C (
.c,.h) - Swift (
.swift) - Kotlin (
.kt) - Go (
.go) - Rust (
.rs) - PHP (
.php) - Ruby (
.rb) - HTML (
.html,.htm) - CSS (
.css) - SCSS (
.scss,.sass) - JSON (
.json) - XML (
.xml) - YAML (
.yaml,.yml) - Markdown (
.md) - SQL (
.sql) - Bash (
.sh,.bash) - Shell (
.sh) - Dockerfile (
Dockerfile) - Plain Text (
.txt)
ProgrammingLanguage- Supported programming languagesCodeTheme- 'light' | 'dark' | 'auto'CodeSnippet- Code snippet structureCodeEditorConfig- Editor configurationSyntaxToken- Syntax highlighting tokenTokenType- Token types for syntax highlighting
- Code snippet manager
- JSON/SQL formatter
- Code generator tools
- Text encoder/decoder
- HTML template maker
- Markdown editor
- Developer documentation
- Code sharing apps
MIT
Ümit UZ umit@umituz.com