Code

Render code snippets and highlighted code blocks, complete with clipboard copying.

Code blocks

Code blocks are rendered by the ProsePre component of @nuxtjs/mdc and code highlighting is done underneath by Shiki.

export default defineNuxtConfig({
  modules: ['@bitrix24/b24ui-nuxt']
})
```ts
export default defineNuxtConfig({
  modules: ['@bitrix24/b24ui-nuxt']
})
```

Language

Syntax highlighting is available for dozens of programming languages.

<script setup lang="ts">
const message = ref('Hello World!')

function updateMessage() {
  message.value = 'Button clicked!'
}
</script>

<template>
  <div>
    <h1>{{ message }}</h1>
    <B24Button @click="updateMessage">
      Click me
    </B24Button>
  </div>
</template>
```vue
<script setup lang="ts">
const message = ref('Hello World!')

function updateMessage() {
  message.value = 'Button clicked!'
}
</script>

<template>
  <div>
    <h1>{{ message }}</h1>
    <B24Button @click="updateMessage">
      Click me
    </B24Button>
  </div>
</template>
```
By default for syntax highlighting, material-theme-lighter and material-theme-palenight VSCode themes are used for light & dark mode respectively.

Filename

Code blocks support filename display with automatic icon detection.

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@bitrix24/b24ui-nuxt']
})
```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['@bitrix24/b24ui-nuxt']
})
```

Line highlighting

Highlight specific lines to draw attention to important parts.

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@bitrix24/b24ui-nuxt'], // This line is highlighted
  css: ['~/assets/css/main.css']
})
```ts [nuxt.config.ts] {2}
export default defineNuxtConfig({
  modules: ['@bitrix24/b24ui-nuxt'], // This line is highlighted
  css: ['~/assets/css/main.css']
})
```

Code diff

Use the diff language to show changes between code versions.

nuxt.config.ts
export default defineNuxtConfig({
  modules: [
-   '@bitrix24/b24ui'
+   '@bitrix24/b24ui-nuxt'
  ]
})
```diff [nuxt.config.ts]
export default defineNuxtConfig({
  modules: [
-   '@bitrix24/b24ui'
+   '@bitrix24/b24ui-nuxt'
  ]
})
```

Inline code

Inline code snippets are rendered by the ProseCode component of @nuxtjs/mdc.

inline code

`inline code`

Color

Use the color prop to change the color of the inline code. Defaults to air-secondary.

inline code

`inline code`{color="air-primary-alert"}

Lang

Use the lang prop to specify the language of the inline code.

nuxt.config.ts

`nuxt.config.ts`{lang="ts-type"}
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24