Docs

Code Highlight

A code snippet in a styled block with a file name, line numbers, highlighted lines and a copy button.

On this page

The Code Highlight widget shows a piece of code exactly as you typed it, in a dark or light block with a file name, a language label, line numbers and a Copy button. You can highlight lines to point readers to the part that matters. Use it for tutorials, documentation or any snippet visitors should copy.

A dark code block titled palette.css with a CSS label and a Copy button, showing thirteen numbered lines of CSS; lines 3 to 6 are highlighted with a blue background and a blue marker on the left
A Code Highlight block with lines 3–6 highlighted.

Add a Code Highlight

Open Insert in the left panel and find Code Highlight in the Content group, or type "code" in the search box. Drag it onto the canvas, or click it to add it next to the selected element. See Add elements.

Paste your code into Code. It is shown as plain text: HTML tags and symbols appear as they are, and nothing in the code runs on your page.

Highlight lines

Type line numbers or ranges in Highlight lines, separated by commas, such as 2, 4-6. Those lines get a colored background and a marker. If your snippet is part of a longer file, set First line number so the numbers match the original.

Note

The widget does not color the code by language. Language sets the label in the header, and the code keeps the colors of the block's Theme. Use highlighted lines to draw attention to parts of the code.

Content tab settings

Content tab · Code
SettingWhat it does
CodeThe code to show, exactly as typed.
LanguageThe label shown in the header: Plain text, HTML, CSS, SCSS, JavaScript, TypeScript, JSX, JSON, PHP, Python, Ruby, Go, Rust, Java, Kotlin, Swift, C, C++, C#, Bash, PowerShell, SQL, YAML, Markdown or Diff. Default: JavaScript. Plain text shows no label.
File name / titleA name in the header, such as fetch-posts.js.
Show language labelShows the language in the header. On by default.
Line numbersNumbers each line. On by default.
First line numberThe number of the first line (0–99999). Default: 1. Shown when Line numbers is on.
Highlight linesLine numbers or ranges to highlight, separated by commas, such as 2, 4-6.
Wrap long linesWraps long lines instead of scrolling sideways. Off by default.
Copy buttonAdds a button that copies the code. On by default.
Copy labelThe button text. Default: Copy. Shown when Copy button is on.
Copied labelThe text shown after copying. Default: Copied!. Shown when Copy button is on.
ThemeDark or Light block. Default: Dark.

Design tab settings

Design tab
SectionSettings
BoxFont size, Code typography, Max height (longer code scrolls inside the block), Tab size, Background, Text color, Code padding, Border radius, Border, Shadow.
HeaderBackground, Text color, Typography.
LinesLine number color (when line numbers are on), Highlighted line background, Highlighted line marker.
Copy buttonText color and Background (with Normal and Hover tabs). Shown when Copy button is on.

The Design tab also has the sections every element shares: Spacing & position, Background & border and Mask. See Spacing, size & position.

Behaviour tab

The Behaviour tab has the settings every element shares: anchor and classes, entrance animations, motion effects, visibility per device, display conditions and interactions. See Visibility.

Tips

  • Keyboard users can focus the code area and scroll it with the arrow keys, so long lines stay reachable.
  • To add HTML that should show as part of the page, rather than as code, use the HTML widget instead.