Code Block
A component used to display code snippets with optional line numbering and line highlighting.
Preview
In this example, line numbers are displayed for lines 3 and 4. You can specify which lines to highlight using the format {3-4}.
Output Markdown
You can directly use the following syntax to create a code block with line numbers and highlight specific lines:
Features
- Language Title: You can use a title for each programming language to render an icon and display a title bar. For example :
javascript:index.js - Line Numbers: Enable line numbers by adding
showLineNumbersafter the opening backticks. - Highlight Lines: Specify lines to highlight using curly braces (e.g.,
{3-4}). - Syntax Highlighting: Use the appropriate language for syntax highlighting.
- Expandable : Allow users to expand and collapse long code blocks using
Expandable
Language Support
Expandable Code
You can make code blocks expandable when they contain many lines of code. The component will show a collapsed view with a "See all N lines" button.
Usage
Add the Expandable keyword after the opening backticks:
Example
Default Behavior
- Default visible lines: 20 lines
- Threshold: Code blocks with more than 20 lines will show the expandable button
- Button text: Shows "See all N lines" (collapsed) or "Collapse" (expanded)
Last updated May 5, 2026