Skip to content

Code Block

Syntax-highlighted via Astro’s built-in <Code> component (Shiki), so no extra highlighting library is needed. Takes the code as a code string prop rather than slotted children, which keeps the highlighter’s real output (not our own markup) in the <pre>.

Button.astro
---
import Button from "@samla/ui/Button.astro";
---

<Button href="/work/">See our work</Button>
  • code: required, the code to highlight
  • filename: optional, shown in the header
  • lang: optional Shiki language id, e.g. astro, css, bash (default plaintext)
  • lineNumbers: boolean
  • copy: boolean, adds the copy button
<CodeBlock
filename="Button.astro"
lang="astro"
copy
lineNumbers
code={`<Button href="/work/">See our work</Button>`}
/>