vue-hljs

Highlight.js plugin for Vue.js 3.0
50,789 19
Install
npm install vue-hljs
Latest Version:3.0.3
Vue:3
Older releases:2
License:BSD-3
Last Updated:Jun 30, 2026
Links: GitHub  ·  npm
Maintainer: sunskyxh

vue-hljs

Overview

ℹ️ Update: Highlight.js has released an official vue plugin since Mar 23, 2021. See highlightjs/vue-plugin.

This is a vue plugin which allows you to highlight code blocks via vue-directive.

Install

npm install vue-hljs highlight.js

or

yarn add vue-hljs highlight.js

Example

import { createApp } from 'vue'
import vueHljs from "vue-hljs";
import hljs from "highlight.js";
//if you want to use default color, import this css file
import "vue-hljs/style.css";

const app = createApp({})
app.use(vueHljs, { hljs })
<div v-highlight>
  <pre>
    <!-- you can specify language by modifing the class attribute -->
    <code class="typescript">...</code>
  </pre>
</div>

Use your own style

This plugin use gruvbox-dark as default style.

You can write your own style or see highlight.js demo. And then import your css file in Vue project entry.

Other similar projects

Related Packages

highlightjs-vue

Highlight Single-File Components of Vue.js Framework

214,587,561 15
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

1,419
vue-mark-text

Vue component for marking/highlighting text

2,264

Version History

Version Released License
3.0.3 BSD-3
3.0.2 BSD-3
3.0.1 BSD-3
3.0.0 BSD-3-Clause
2.0.0 BSD-3