Skip to content

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.

  • Full TypeScript language service
  • Real-time error checking and IntelliSense
  • Auto-completion and parameter hints
  • Type checking with immediate feedback
  • Light theme (default)
  • Dark theme (vs-dark)
  • Matches your documentation site theme
  • Lazy-loaded for optimal page performance
  • Client-side hydration only when needed
  • Graceful fallback for no-JavaScript environments
  • 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}
/>

| 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 |

The live code editor includes:

  • Keyboard navigation support
  • Screen reader compatibility
  • High contrast theme support
  • Focus management and ARIA labels
  • Graceful degradation without JavaScript