Documentation

Asgard

Getting started

Theming

Guides

Layout

Docking

Inputs & forms

Button

Switch

Checkbox

Radio

Select

Slider

TextBox

Upload

ImageCropper

Pickers

Color picker

Calendar

Time picker

DateTime input

Data display

Card

Accordion

Typography

Progress

DataTable

TreeView

SyntaxColor

MarkdownRenderer

Terminal

Layout & docking

Grid

Splitter

SDiv

Dock

Theme switcher

Media query

Feedback & overlays

Alert

Toast

Tooltip

Popups

Drawer

FloatingPanel

FloatingWindow

Navigation & chrome

Breadcrumb

Stepper

Toolbar

Ribbon

ContextMenu

FeatureTour

Documentation

Asgard

Getting started

Theming

Guides

Layout

Docking

Inputs & forms

Button

Switch

Checkbox

Radio

Select

Slider

TextBox

Upload

ImageCropper

Pickers

Color picker

Calendar

Time picker

DateTime input

Data display

Card

Accordion

Typography

Progress

DataTable

TreeView

SyntaxColor

MarkdownRenderer

Terminal

Layout & docking

Grid

Splitter

SDiv

Dock

Theme switcher

Media query

Feedback & overlays

Alert

Toast

Tooltip

Popups

Drawer

FloatingPanel

FloatingWindow

Navigation & chrome

Breadcrumb

Stepper

Toolbar

Ribbon

ContextMenu

FeatureTour

Data display

Render syntax-highlighted code.

A themable, syntax-highlighted code viewer powered by a Monarch-compatible tokenizer.

Key features:

  • Line numbers, indent guides and scope folding
  • Line highlighting, alternate row coloring and git-diff indicators
  • Inline diagnostics and margin decorators (breakpoints, warnings)
  • Word wrap, custom tokenColorMap overrides and code excerpts
  • Built-in languages: TypeScript, JavaScript, JSON, CSS, HTML, Python
Loading preview…
When to use it
  • Code samples in docs and blogs
  • Read-only file / snippet viewers
  • Diff and review surfaces
Properties
PropTypeDefaultDescription
codestringSource code to render.
languageMonarchLanguageMonarch language definition for tokenization (e.g. typescriptLanguage). This is an object, not a string.
size'small' | 'normal' | 'large''normal'Font size of the rendered code.
showLineNumbersbooleantrueShow the line-number gutter.
showIndentGuidesbooleanfalseDraw vertical indent guides.
showFoldingbooleanfalseEnable indent-based code folding controls.
highlightedLinesnumber[]Line numbers to highlight.
alternateLineColorbooleanfalseZebra-stripe alternate lines.
startLineNumbernumber1First line number, useful for code excerpts.
wordWrapbooleanfalseWrap long lines instead of scrolling horizontally.
tabSizenumber4Number of spaces a tab renders as.
maxHeightnumber | stringMaximum height before the viewer scrolls.
trailingLinesnumber0Blank lines appended after the code.
tokenColorMapRecord<string, string>Override individual token colors.
Notes
  • language is a MonarchLanguage object. Import a built-in (typescriptLanguage, jsonLanguage, …) or supply your own definition.
  • For prose with fenced code blocks, MarkdownRenderer wraps SyntaxColor for you, no language object needed.
  • Use startLineNumber + highlightedLines to render and emphasize an excerpt from a larger file.
Presets