CodeEditor

Data Display

Monaco-based code editor with syntax highlighting, language detection, theme sync, and IntelliSense integration

CodeEditor

A fully featured code editor component with themes, variants, sizes, toolbar placement and status bar support, designed for Saha UI docs and playgrounds.

Global theme

The selected theme is applied to most examples below.

Basic usage

Use defaultValue for uncontrolled editing, or value with onChange for a controlled editor.

Loading...
Ln 1, Col 1
tsx
Spaces: 2

This example uses defaultValue with a tsx language and a visible toolbar.

Themesaha-ui-dark
Variantprimary
Status barenabled

Use this pattern for playgrounds, docs, and live examples where users can experiment with the code.

Variants

CodeEditor supports the same variant system as other Saha UI components. Use variants to blend the editor into your layout.

defaultvariant
Loading...
primaryvariant
Loading...
secondaryvariant
Loading...
accentvariant
Loading...
successvariant
Loading...
warningvariant
Loading...
errorvariant
Loading...
infovariant
Loading...
outlinevariant
Loading...
ghostvariant
Loading...

Sizes

Use the size prop to adjust spacing and font-size for inline snippets or full playgrounds.

smsize
Loading...
Ln 1, Col 1
tsx
Spaces: 2
defaultsize
Loading...
Ln 1, Col 1
tsx
Spaces: 2
lgsize
Loading...
Ln 1, Col 1
tsx
Spaces: 2
xlsize
Loading...
Ln 1, Col 1
tsx
Spaces: 2

Toolbar placement

Choose between an inline toolbar (always visible) or a floating compact toolbar that overlays the editor.

Inline toolbarRecommended

The toolbar is rendered inside the editor at the top.

Loading...
Ln 1, Col 1
tsx
Spaces: 2
Floating toolbarOverlay

The toolbar is overlaid in the corner with blur and shadow.

Loading...
Ln 1, Col 1
tsx
Spaces: 2

Themes

Switch between built-in themes. Combine theme with variant and size to match your application look.

saha-ui-darkSaha
Loading...
saha-ui-lightSaha
Loading...
vscode
Loading...
dark
Loading...
light
Loading...
github
Loading...
monokai
Loading...
dracula
Loading...
nord
Loading...
solarized
Loading...

Usage Guidelines

When to Use

  • Code playgrounds
  • Configuration editors
  • Live coding

Accessibility

  • Monaco accessibility features
  • Keyboard navigation in editor

Performance

  • Monaco lazy loading
  • Web worker syntax highlighting

Common Mistakes

  • Not setting initial language
  • Too small height for content

Frequently Asked Questions

CodeEditor uses Monaco Editor, the same editor that powers VS Code.
Yes, CodeEditor supports 50+ programming languages with syntax highlighting.

View on GitHub

See the full source code on GitHub