Expressive Code plugin examples
/ 1 min read / Astro Cactus
Table of Contents
This page collects small examples for the extra Expressive Code plugins enabled on this site.
File icons
File icons add a recognizable file-type icon to code frames when the block title contains a filename.
import expressiveCode from "astro-expressive-code";
export default { integrations: [expressiveCode()],};Fullscreen
Fullscreen adds a button to titled code blocks so longer examples can be read in a focused overlay.
export function createSlug(input: string) { return input .trim() .toLowerCase() .replace(/['"]/g, "") .replace(/[^a-z0-9]+/g, "-") .replace(/^-|-$/g, "");}
export function createPostUrl(slug: string) { return `/posts/${createSlug(slug)}/`;}Caption
Caption turns text wrapped in trailing --- lines into a caption below the rendered code block.
pnpm checkThe caption appears below the code block and can include inline code.
Output
Output mode separates entered commands from the result they produce, keeping terminal examples easier to scan.
pnpm astro checkResult (23 files):- 0 errors- 0 warnings
Color chips
Color chips show small previews beside CSS color values, including transparent colors.
:root { --brand: #2bbc8a; --accent: rgb(238 99 82); --surface: hsl(210 20% 98%); --overlay: transparent; color: CanvasText;}
.notice { border-color: rebeccapurple; box-shadow: 0 0 0 2px rgb(43 188 138 / 35%);}