vue-code-highlighter
Vue component for highlighting code or syntax with modern style, copy functionality, multicode and powered by Highlight.js
18,948
10
| Install | |
|---|---|
npm install vue-code-highlighter |
|
| Latest Version: | 1.1.3 |
| Vue: | 3 |
| License: | ISC |
| Last Updated: | Mar 3, 2025 |
| Links: | GitHub · npm |
Maintainer: ichsanputr
Vue Code Highlighter
Vue component for highlighting code or syntax with modern style, copy functionality, multicode and powered by Highlight.js
Installation
npm install vue-code-highlighter highlight.js
// or use yarn
yarn add vue-code-highlighter highlight.js
Usage
Importing
This package support either composition and options api with typescript or javascript.
import { VueCodeHighlighter, VueCodeHighlighterMulti } from 'vue-code-highlighter';
import 'vue-code-highlighter/dist/style.css'
This package does not need to call CSS from the highlight.js package because I have already wrapped it. What you need to do is install the highlight.js package.
Example & Demo
Example code and demo available in ichsanputr.github.io/vue-code-highlighter
Props
There are 2 types of components, namely VueCodeHighlighter and VueCodeHighlighterMulti, both of them have different props.
VueCodeHighlighter
| Attribute | Type | Is Required | Description |
|---|---|---|---|
| lang | String | true | Code languange from Highlighter cheatset, see Supported languange |
| code | String | true | Plain code which will be displayed, please wrap your code using backtick (``) |
| title | String | no | Custom title in header |
| disableCopy | Boolean | no | Disable copy button and copy functionality to code |
VueCodeHighlighterMulti
| Attribute | Type | Is Required | Description |
|---|---|---|---|
| code | Array | true | See example below |
| disableCopy | Boolean | no | Disable copy button and copy functionality to code |
const codeMulti = [
{
lang: "js",
title: "vue",
code: codeVue.value
},
{
lang: "html",
code: codeHtml.value,
title: 'html'
},
{
lang: "css",
code: codeCss.value,
},
]
Version History
| Version | Released | License |
|---|---|---|
| 1.1.3 | ISC | |
| 1.1.2 | ISC | |
| 1.1.1 | ISC | |
| 1.1.0 | ISC | |
| 1.0.9 | ISC | |
| 1.0.8 | ISC | |
| 1.0.7 | ISC | |
| 1.0.6 | ISC | |
| 1.0.5 | ISC | |
| 1.0.4 | ISC | |
| 1.0.3 | ISC | |
| 1.0.2 | ISC | |
| 1.0.1 | ISC | |
| 1.0.0 | ISC |