Vue CodeBlock
PrismJS Active

Vue 3 CodeBlock

by WebDevNerdStuff

v2.3.5

# Installation

# Description

The Vue 3 CodeBlock component leverages the power of PrismJS or Highlight.js to provide syntax highlighting for code blocks within your application. The component takes a prop, which is the code to be highlighted, and uses PrismJS or Highlight.js to render the code with syntax highlighting. The component supports a variety of programming languages and can be customized with different themes to match your application's design. With this component, your users can display their code snippets with ease and clarity, making it easier to share and collaborate on code within your application.

# Usage

# Props

#

Name
Type
Default
Description
#browserWindowbooleanfalseTo give the code block a browser window look.
#codeobject | string | numberThe code to be displayed in the code block.
#codeBlockRadiusstring0.5remThe border radius of the code block.
#copyButtonbooleantrueTo show a copy button within the code block.
#copyFailedTextstringCopy failed!The text to be displayed when the code copy failed.
#copyIconsbooleantrueTo show the copy icons on the copy code tab.
#copySuccessTextstringCopied!The text to be displayed when the code copy was successful.
#copyTabbooleantrue?To show the copy code tab.
#copyTextstringCopy CodeThe text to be displayed on the copy tab.
#cssPathstring | undefinedundefinedUsed to load the css from a specified location instead of the component using the CDN location. If you want to dynamically change the theme, you will also need to change the theme prop.
#floatingTabsbooleantrueTo make the tabs float on top of the code block.
#heightstring | numberautoThe height of the code block.
#highlightjsbooleanfalseSpecifies that the Highlight.js library should be used. * Required if prismjs prop is not set.
#indentnumber4The number of spaces to indent the code for json.
#labelstringThe label to be displayed on the code block.
#langstringjavascriptThe language of the code.
#maxHeightstring | numberautoThe max height of the code block.
#persistentCopyButtonbooleanfalseTo show a persistent copy button within the code block.
#prismjsbooleantrueSpecifies that the PrismJS library should be used. * Required if highlightjs prop is not set.
#prismPluginbooleanfalseSpecifies that a PrismJS plugin is being used. This is needed for the plugin to work properly.
#runTabbooleanfalseTo show the run tab.
#runTextstringRunThe text to be displayed on the run tab.
#tabGapstring0.25remThe gap between the tabs.
#tabsbooleanfalseTo show the tabs. This will show/hide all tabs.
#themestring | booleanneon-bunny

The theme to be used for the code block. Available options include:

false - When you are loading the theme's styles yourself.

Neon Bunny Themes
neon-bunny
neon-bunny-carrot

PrismJS Themes

Highlight.js Themes

# Events

Name
Description
#runThe event emitted when the run tab is clicked.
#update:copy-statusThe event emitted when the copy status is updated.

# Slots

NameDescription
#copyButton Slot for the copy button inside the code block of the component.
#label Slot for the label of the component.
#tabs Slot for the tabs of the component.

# Examples

Languages

Additional Languages

PrismJS does not load all languages by default. In order to use additional languages you will need to import that languages component.

Plugins

PrismJS does not load all plugins by default. In order to use additional plugins you will need to import them. Please note that not all plugins may work with this component.

Tabs

Copy Button

Browser Window

Other Prop Examples

# Developer Playground

Setup the Playground

This will create a file for you to adjust and play with.
/src/playground/PlaygroundPage.vue

# License

Copyright © 2025 WebDevNerdStuff
Licensed under the MIT License
Buy Me A Coffee