Skip to content

ContentCodeBlock ​

A block of code with line numbers, highlighted lines, wrapping, a maximum height, a copy button and a pluggable highlighter.

ts
import { ContentCodeBlock } from '@zairakai/vue-components/Content'

Usage ​

vue
<ContentCodeBlock />

Example ​

hello.jsjs
const greeting = 'Hello'
console.log(greeting)
vue
<template>
  <ContentCodeBlock
    title="hello.js"
    language="js"
    :code="`const greeting = 'Hello'\nconsole.log(greeting)`"
    line-numbers
    :highlight-lines="[2]"
  />
</template>

Props ​

NameTypeDefaultDescription
idstring
classstring
codestringThe code. It can also be given as the text of the default slot.
languagestring
titlestringA title: a file name, for example.
lineNumbersbooleanfalse
highlightLinesstring|arrayundefinedThe lines to highlight: "2,4-6" or [2, "4-6"].
wrapbooleanfalse
maxHeightstringA maximum height (any CSS length): the code scrolls inside.
copyablebooleantrue
copyLabelstring'Copy'
copiedLabelstring'Copied'
highlighterfuncTurns the code into highlighted HTML: (code, language) => string. The result is rendered as HTML: only give it the output of a highlighter you trust.

See Theming for the class hooks and the data-* state of the components.

Documentation of 1.4.4 , built from 8e9b054 on 1.4.4 by pipeline #2989941079 on 2026-10-26.