Skip to content

Vue Syntax HighlighterVue 3 code highlighting that stays fast

Pluggable engines, semantic themes, deterministic SSR, and a simple API for everyday code blocks.

Install ​

bash
npm install vue-syntax-highlighter shiki
bash
pnpm add vue-syntax-highlighter shiki
bash
yarn add vue-syntax-highlighter shiki
bash
bun add vue-syntax-highlighter shiki

Import the stylesheet once:

ts
import 'vue-syntax-highlighter/styles.css'

Then render:

vue
<script setup lang="ts">
import { SyntaxHighlighter } from 'vue-syntax-highlighter'

const code = 'const answer = 42'
</script>

<template>
  <SyntaxHighlighter :code="code" language="javascript" />
</template>

That is the whole zero-configuration path: Shiki is the default engine, vsh-light is the default theme, and no provider or plugin is required.

Read the Quick Start · Basic Usage · Advanced Usage

Try it ​

Semantic tokens, not engine-native styles ​

Coupling themes to engine output makes theme switches expensive and makes server rendering unpredictable. This library keeps tokenization independent from appearance:

ts
// Engine output: text + semantic type only.
{ text: 'const', type: 'keyword' }

// Appearance: CSS custom properties selected by scheme.
// --vsh-light-token-keyword-color / --vsh-dark-token-keyword-color

That one decision makes the cache theme-independent, keeps SSR markup small, and lets every adapter share the same theme system.

Released under the MIT License.