Live Code Editor
Live Code Editor
Section titled “Live Code Editor”Experience the power of VS Code’s Monaco Editor integrated directly into our documentation. This interactive code editor provides full TypeScript support, IntelliSense, error checking, and syntax highlighting.
Basic TypeScript Example
Section titled “Basic TypeScript Example”React Component Example
Section titled “React Component Example”Dark Theme Example
Section titled “Dark Theme Example”Read-Only Code View
Section titled “Read-Only Code View”Features
Section titled “Features”🎯 TypeScript Support
Section titled “🎯 TypeScript Support”- Full TypeScript language service
- Real-time error checking and IntelliSense
- Auto-completion and parameter hints
- Type checking with immediate feedback
🎨 Themes
Section titled “🎨 Themes”- Light theme (default)
- Dark theme (
vs-dark) - Matches your documentation site theme
⚡ Performance
Section titled “⚡ Performance”- Lazy-loaded for optimal page performance
- Client-side hydration only when needed
- Graceful fallback for no-JavaScript environments
🔧 Customization
Section titled “🔧 Customization”- Configurable height and read-only mode
- Multiple programming languages supported
- Custom compiler options for advanced use cases
---import CodeEditorAstro from '../../../components/interactive/CodeEditorAstro.astro'---
<CodeEditorAstro defaultValue="const example = 'Hello World!'" language="typescript" height={300} theme="vs-dark" readOnly={false}/>Props Reference
Section titled “Props Reference”| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string | '' | Initial code content |
language | string | 'typescript' | Programming language |
theme | 'light' | 'vs-dark' | string | 'light' | Editor theme |
height | number | string | 400 | Editor height in pixels or CSS string |
width | number | string | '100%' | Editor width in pixels or CSS string |
readOnly | boolean | false | Whether editor is read-only |
lineNumbers | 'on' | 'off' | 'relative' | 'interval' | 'on' | Whether to show line numbers |
wordWrap | 'on' | 'off' | 'wordWrapColumn' | 'bounded' | 'on' | Whether to enable word wrap |
fontSize | number | 14 | Font size in pixels |
minimap | boolean | false | Whether to show the minimap |
folding | boolean | true | Whether to show folding controls |
tabSize | number | 2 | Tab size in spaces |
insertSpaces | boolean | true | Whether to use spaces for indentation |
enableTypeScript | boolean | true | Whether to enable TypeScript language service |
title | string | - | Optional title for accessibility |
Accessibility
Section titled “Accessibility”The live code editor includes:
- Keyboard navigation support
- Screen reader compatibility
- High contrast theme support
- Focus management and ARIA labels
- Graceful degradation without JavaScript