Display.code

Code

Displays a syntax-highlighted code block. Useful for showing examples, logs, or output from scripts.

ctx.ui.display.code({ code, language });

Config


code
string

The code content to display.


language
string

The programming language used for syntax highlighting (e.g., "javascript", "python", "json"). Optional—defaults to plain text if not provided.

Usage

Use code blocks to display read-only code or structured output on a page.

ctx.ui.page({
  title: "API Example",
  content: [
    ctx.ui.display.code({
      code: `console.log('Hello, world!');`,
      language: "typescript",
    }),
  ],
});