vitepress-plugin-tabs
A plugin that adds syntax for showing content in tabs.
Installation
sh
npm i -D vitepress-plugin-tabs
npm i -D vitepress-plugin-tabs
Usage
After installing the plugin, you'll need to edit both App Config and Theme Config.
ts
// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
export default defineConfig({
markdown: {
config(md) {
md.use(tabsMarkdownPlugin)
}
}
})
// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
export default defineConfig({
markdown: {
config(md) {
md.use(tabsMarkdownPlugin)
}
}
})
ts
// .vitepress/theme/index.ts
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
export default {
extends: DefaultTheme,
enhanceApp({ app }) {
enhanceAppWithTabs(app)
}
} satisfies Theme
// .vitepress/theme/index.ts
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
export default {
extends: DefaultTheme,
enhanceApp({ app }) {
enhanceAppWithTabs(app)
}
} satisfies Theme
Syntax
Tabs with non-shared selection state
md
:::tabs
== tab a
a content
== tab b
b content
:::
:::tabs
== tab a
a content 2
== tab b
b content 2
:::
:::tabs
== tab a
a content
== tab b
b content
:::
:::tabs
== tab a
a content 2
== tab b
b content 2
:::
a content
a content 2
Tabs with shared selection state
md
:::tabs key:ab
== tab a
a content
== tab b
b content
:::
:::tabs key:ab
== tab a
a content 2
== tab b
b content 2
:::
:::tabs key:ab
== tab a
a content
== tab b
b content
:::
:::tabs key:ab
== tab a
a content 2
== tab b
b content 2
:::
a content
a content 2