Reference

Guide

code

An inline code block for code snippets and examples.

Preview

Default snippet

/site/snippets/blocks/code.php
<pre><code class="language-<?= $block->language()->or('text') ?>"><?= $block->code() ?></code></pre>

Default blueprint

name: field.blocks.code.name
icon: code
preview: code
fields:
  code:
    label: field.blocks.code.name
    type: textarea
    placeholder: field.blocks.code.placeholder
    buttons: false
    font: monospace
  language:
    label: field.blocks.code.language
    type: select
    default: text
    options:
      bash: Bash
      basic: BASIC
      c: C
      clojure: Clojure
      cpp: C++
      csharp: C#
      css: CSS
      diff: Diff
      elixir: Elixir
      elm: Elm
      erlang: Erlang
      go: Go
      graphql: GraphQL
      haskell: Haskell
      html: HTML
      java: Java
      js: JavaScript
      json: JSON
      latext: LaTeX
      less: Less
      lisp: Lisp
      lua: Lua
      makefile: Makefile
      markdown: Markdown
      markup: Markup
      objectivec: Objective-C
      pascal: Pascal
      perl: Perl
      php: PHP
      text: Plain Text
      python: Python
      r: R
      ruby: Ruby
      rust: Rust
      sass: Sass
      scss: SCSS
      shell: Shell
      sql: SQL
      swift: Swift
      typescript: TypeScript
      vbnet: VB.net
      xml: XML
      yaml: YAML

Default Vue Component

https://github.com/getkirby/kirby/blob/master/panel/src/components/Blocks/Types/Code.vue