Tiramisu Docs

Content

Code Blocks

Display syntax-highlighted code with Shiki, tabbed code blocks, language icons, and file imports.

Display syntax-highlighted code using the codeblock function. Highlighting is powered by Shiki.

Basic Usage

tiramisu
codeblock { language = typescript, "const x = 42" }
Preview
typescript
const x = 42

Multi-line Code

Single quotes work for multi-line code, too:

tiramisu
codeblock { language = typescript, "function greet(name: string) {
  return \\"Hello, \\" + name
}

greet(\\"World\\")" }

Alternatively, you can wrap your code samples in multiple quotes so you don't have to use \ for escaping:

tiramisu
codeblock { language = typescript, """function greet(name: string) {
  return "Hello, " + name
}

greet("World")""" }
Preview
typescript
function greet(name: string) {
  return "Hello, " + name
}

greet("World")

The number of starting and ending quotes doesn't matter, as long as they match.

Loading Code from Files

Use readfile to load source code from external files instead of embedding it:

tiramisu
codeblock { language = csv, readfile { src = sample-data.csv } }

This keeps your documentation in sync with actual source files. The path is relative to the .tiramisu file.

Language Icons

Code blocks and tabbed code blocks automatically display a language icon in the header. Icons are detected from the language name using the devicon-plain icon set.

You can override the auto-detected icon with the icon parameter:

tiramisu
codeblock { language = typescript, icon = "lucide:file-code", "const x = 42" }

The icon parameter accepts any Iconify icon name.

Tabbed Code Blocks

Use codetabs to group related code blocks with tab switching:

tiramisu
codetabs { group = pkg,
  codetab { label = bun, icon = simple-icons:bun, language = bash, "bun add my-package" },
  codetab { label = npm, language = bash, "npm install my-package" },
  codetab { label = yarn, language = bash, "yarn add my-package" }
}
Preview
bun add my-package

Group Syncing

When multiple code tab groups share the same group name, selecting a tab in one automatically switches the matching tab in all others — even across pages. The selection is persisted in localStorage.

Supported Languages

Any language supported by Shiki works. Common examples:

LanguageValue
TypeScripttypescript or ts
JavaScriptjavascript or js
Bash / Shellbash or shell
CSScss
HTMLhtml
JSONjson
Pythonpython
Rustrust
Gogo

Inline Code

For inline code, use the code function:

tiramisu
Use code { myFunction() } in your code.