HighlightCompo Component

A Svelte component for syntax highlighting with copy-to-clipboard functionality, expandable code blocks, and support for multiple languages (Svelte, TypeScript, JavaScript, JSON, YAML, Markdown). Features automatic library import replacement and responsive overflow detection.

Features

Props

PropTypeDefaultDescription
codestringrequiredCode to highlight
langSupportedLanguage"svelte"Language: "svelte", "ts", "js", "json", "yaml", "md"
contentClassstring"overflow-hidden"CSS class for content wrapper
classstringundefinedCSS class for outer container
replaceLibstring | false"svelte-rune-highlight"Replace $lib imports or disable with false
showCopybooleantrueShow or hide the copy button

Examples

Svelte

JavaScript

JSON

Markdown

TypeScript

YAML