CodeBlock
v1.0.7Updated 27 Aug 2026Syntax-highlighted code display built on highlight.js with design-token colors that follow the app theme in both light and dark schemes (no hljs stylesheet). Supports explicit language or auto-detect, line numbers, per-l
Preview
Live · 13 stories▸Why this is recommendedcodesyntaxhighlightsnippet+4
The default, out-of-the-box CodeBlock.
- ✓API documentation panels
- ✓Webhook / integration setup guides
- ✓Config and SQL snippets in admin tools
- ✓Developer settings pages
- highlight.js coloring mapped to design tokens (light + dark)
- Explicit language or automatic detection with language tag
- Optional line-number gutter (sticky on horizontal scroll)
- highlightLines per-line emphasis (1-based)
- Soft-wrap toggle button (aria-pressed, controlled or uncontrolled)
- Copy button with copied feedback + aria-live announcement
- Filename / label header slot
- maxHeight collapse with fade hint and expand/collapse footer (aria-expanded)
- Focusable, labelled scroll region for keyboard users
- Sizes: sm / md / lg
- i18n: labels prop overrides header-button arias, copy announcement, expand footer and region labels (DEFAULT_CODE_BLOCK_LABELS)
- ✕Editable code (use a code editor)
- ✕Rendering full markdown documents (use Markdown)
- ✕Side-by-side diffs (use DiffViewer)
Install
Ask your agent, or call the MCP tool directly. The resolved bundle is written into your project.
Usage
Tick variants in the left menu — each adds a tab with that variant’s real story source, the same code the preview above renders.
Props
codeSource code as plain text (never HTML)
yeslanguagehighlight.js language id; auto-detected when omitted or unknown
—showLineNumbersRender a line-number gutter
—highlightLines1-based lines to visually emphasise
—wrapControlled soft-wrap state (defaultWrap / onWrapChange for uncontrolled)
—titleFilename / label header slot
—maxHeightCollapse height (px) with expand/collapse footer
—expandedControlled expanded state (defaultExpanded / onExpandedChange for uncontrolled)
—sizeCode text size
—labelsOverride built-in UI strings (wrap/copy aria-labels, copied live-region, 'Show all {count} lines' footer, code-region labels) for i18n; English defaults exported as DEFAULT_CODE_BLOCK_LABELS. Line counts format via LocaleProvider
—