@hsorby/vue3-highlightjs

Syntax highlighting with highlight.js for Vue.js 3.x
1,404 1
Install
npm install @hsorby/vue3-highlightjs
Latest Version:2.0.0
Vue:3
License:ISC
Last Updated:Sep 27, 2026
Links: GitHub  ·  npm
Maintainer: hsorby

vue3-highlightjs

Vue.js 3.x syntax highlighting made easy, using highlight.js.

Install

npm install --save @hsorby/vue3-highlightjs

Usage

import { createApp } from 'vue'
import { installVue3Highlightjs } from '@hsorby/vue3-highlightjs'
import 'highlight.js/styles/solarized-light.css'

const app = createApp({})

app.use(installVue3Highlightjs)

In a single-file component:

<pre v-highlightjs="sourcecode"><code class="javascript"></code></pre>

<pre v-highlightjs><code class="javascript">const s = new Date().toString()</code></pre>

Languages

To keep bundles small, only the highlight.js core and the following languages are registered by default:

bash, cmake, cpp, javascript, json, markdown, plaintext, python, shell, xml

(plus their aliases, e.g. c++, py, html, console).

Register extra languages with the languages option:

import rust from 'highlight.js/lib/languages/rust'
import yaml from 'highlight.js/lib/languages/yaml'

app.use(installVue3Highlightjs, { languages: { rust, yaml } })

Set defaultLanguages: false to register only the languages you pass in.

The underlying highlight.js instance is also exported as hljs if you need to register languages or configure highlight.js directly:

import { hljs } from '@hsorby/vue3-highlightjs'

Upgrading from 1.x

Version 1.x bundled every highlight.js language (~900 kB minified). Version 2 registers only the default set above; code blocks in other languages fall back to auto-detection among the registered languages. Add any other languages you need with the languages option.

Related Packages

vue3-highlightjs

Syntax highlighting with highlight.js for Vue.js 3.x

280,629 28
vue-highlighter

Vue directive for highlight multiple istances of a word

5,989 37
vue-highlight-words

Vue component to highlight words within a larger body of text

625,582 80
docsify-highlight

Build From source code

3,774 1
@kognity/vue-yellow-marker

Adds a text selection and highlighting functionality to your Vue components

2,559

Version History

Version Released Vue License
2.0.0 ^3.0.0 ISC
1.1.0 ^3.0.0 ISC
1.0.7 ^3.0.0 ISC
1.0.6 ^3.0.0 ISC
Pre-releases (2)
Version Released Vue License
1.0.7-rc.2 ^3.0.0 ISC
1.0.7-rc.1 ^3.0.0 ISC