Portfolio Demo Blockset is the platform's own block library. Every block on these pages is server-rendered, FSE-native, and used in real demos on the hub. See the platform →Built by Philip Rehberger

SFP-BLOCKS/CODE-SNIPPET

Code snippet

A styled code snippet block with language label, optional caption, and a copy-to-clipboard button. New as of Blockset; you’re reading the result on this page already — every example markup on every per-block docs page is rendered by code-snippet.

Live

html
<!-- wp:paragraph -->
<p>Hello, block.</p>
<!-- /wp:paragraph -->

Attributes

AttributeTypeDefaultDescription
codestringsample markupThe code body. Plain text; rendered as-is in a <code> element
languagestring"html"Language tag shown in the header label (display only; no syntax highlighting)
captionstringemptyOptional italic caption below the code
showCopybooleantrueShow the copy-to-clipboard button

Example markup

html
<!-- wp:sfp-blocks/code-snippet {"code":"function greet() {\n  console.log(\"hello\");\n}","language":"javascript","caption":"A tiny example."} /-->
Paste this in any block-editor view (or in a theme template) to drop the block in.