Blocks

Code Snippet Block

2 min read

> Syntax-highlighted code blocks with copy functionality for technical documentation.


Overview

The Code Snippet block displays formatted code with syntax highlighting for over 20 programming languages. It includes a one-click copy button, optional line numbers, and customizable display options perfect for documentation, tutorials, and technical content.


Fields

FieldDescription
HeadingOptional section title above the code
SubheadingSupporting text below the heading
LanguageProgramming language for syntax highlighting
FilenameOptional filename display above the code
CodeThe code content to display (required)
Line PrefixLine indicator style: Numbers, Dollar sign, or Arrow
Show Line NumbersDisplay line prefixes
Show Copy ButtonEnable one-click copy to clipboard
Show Language BadgeDisplay the language indicator
Max HeightScrollable height limit for long code
Content WidthControl the maximum width of the content area
AnimationEntrance animation effect

Supported Languages

The block supports syntax highlighting for:

CategoryLanguages
WebJavaScript, TypeScript, HTML, CSS, SCSS, JSX, TSX, Vue
BackendPHP, Python, Ruby, Go, Rust, Java, C#, C++
DataJSON, YAML, SQL
MobileSwift, Kotlin
DevOpsBash, Docker, Nginx, Apache
OtherMarkdown, Plain Text

Line Prefix Options

StyleDisplay
NumbersSequential line numbers (1, 2, 3...)
DollarShell-style prompt ($)
ArrowArrow indicator (>)

Max Height Options

OptionBehavior
NoneShow all code (no scroll)
Small300px max height
Medium400px max height
Large500px max height
XL600px max height

Tips

  • Use the filename field to indicate the file being shown
  • Dollar sign prefix works well for terminal/shell commands
  • Enable max height for long code snippets to prevent page bloat
  • The copy button copies code without line numbers

Examples

Choose Theme