Skip to content

Code Block Icons

Once the plugin is installed, code fences automatically get a small icon. Icons are chosen either by the language or by the filename in the block’s title.


  1. astro.config.mjs
    Icons({
    codeblock: true,
    extractSafelist: true,
    starlight: { ... },
    })
  2. .gitignore
    .starlight-icons
  3. Install the Material Icon Theme collection
    Section titled “Install the Material Icon Theme collection”
    Terminal window
    npm i -D @iconify-json/material-icon-theme
```ts title="app.ts"
console.log('hi')
```

Rendered

app.ts
console.log('hi')

```md title="README.md"
# README
```

Rendered

README.md
# README

Set CSS variables to configure codeblock icons.

src/styles/custom.css
:root {
--spi-codeblock-icon-size: 1.2rem;
--spi-codeblock-icon-gap-right: 0.5rem;
--spi-codeblock-icon-gap-left: 0.5rem;
}