Code Tabs
Less than 1 minute
The theme provides you code tabs support.
Config
// .vuepress/config.ts
import { defineUserConfig } from "vuepress";
import { hopeTheme } from "vuepress-theme-hope";
export default defineUserConfig({
theme: hopeTheme({
plugins: {
mdEnhance: {
codetabs: true,
},
},
}),
});
// .vuepress/config.js
import { hopeTheme } from "vuepress-theme-hope";
export default {
theme: hopeTheme({
plugins: {
mdEnhance: {
codetabs: true,
},
},
}),
};
Usage
This is the same as tabs function, but it's special built for code blocks.
Only code fence after @tab
marker is allowed inside code tabs, other Markdown content will be ignored.
Demo
Install VuePress Theme Hope:
pnpm add -D vuepress-theme-hope
yarn add -D vuepress-theme-hope
npm i -D vuepress-theme-hope
Install VuePress Plugin Markdown Enhance:
pnpm add -D vuepress-plugin-md-enhance
yarn add -D vuepress-plugin-md-enhance
npm i -D vuepress-plugin-md-enhance
Code
Install VuePress Theme Hope:
::: code-tabs#shell
@tab pnpm
```bash
pnpm add -D vuepress-theme-hope
```
@tab yarn
```bash
yarn add -D vuepress-theme-hope
```
@tab:active npm
```bash
npm i -D vuepress-theme-hope
```
:::
Install VuePress Plugin Markdown Enhance:
::: code-tabs#shell
@tab pnpm
```bash
pnpm add -D vuepress-plugin-md-enhance
```
@tab yarn
```bash
yarn add -D vuepress-plugin-md-enhance
```
@tab:active npm
```bash
npm i -D vuepress-plugin-md-enhance
```
:::