vuepress-plugin-tabs

npmopen in new windowdownloadsopen in new windowlicenseopen in new window

This plugin is inspired by vuepress-plugin-element-tabsopen in new window, but for Vue 3.x and VuePress 2.x

VuePress is evolving rapidly, and there's no stable version yet. This plugin is only tested with VuePress version 2.0.0-beta.60

Install

This plugin requries VuePress>=2.0.0open in new window

yarn add -D @snippetors/vuepress-plugin-tabs
// .vuepress/config.js
import tabsPlugin from '@snippetors/vuepress-plugin-tabs'

export default {
  plugins: [
    tabsPlugin(options),
  ],
}

Options

OptionDescriptionTypeAccepted ValuesDefault
eventsevents to dispatch when the component is updatedArray[String]-[]

There is only one possible option, events, which is an array of event names. When this component is updated, these events will be dispatched.

For a setting like

module.exports = {
  plugins: ["@snippetors/vuepress-plugin-tabs", ["event1", "event2"]],
};

these events will be dispatched like

window.dispatchEvent(new Event("event1"));
window.dispatchEvent(new Event("event2"));

You can add listeners to the events to get notified when the component is updated.

window.addEventListener("event1", callbackOfEvent1);

Usage

:::: tabs [tabs attributes..]

::: tab tab1 [tab attributes..]

content 1

:::

::: tab tab2 [tab attributes..]

content 2

:::

::::

Tabs Attributes

AttributeDescriptionTypeAccepted ValuesDefault
typetype of TabStringcard/border-cardborder-card
tab-positionposition of tabsStringtop/right/bottom/lefttop
stretchwhether width of tab automatically fits its containerBoolean-false

Tab Attributes

AttributeDescriptionTypeAccepted ValuesDefault
labeltitle of the tabString--
eagerwhether the tab is eagerly renderedBoolean-false

Note: The tab attribute eager has to be decleared as the last element

Preview

Demo 1

:::: tabs

::: tab tab 1

content 1

:::

::: tab tab 2

content 2

:::

::::

Demo 2

:::: tabs type:card tab-position:bottom

::: tab A

content 1

:::

::: tab a tab with eager in its name

Note that this content won't be eagerly loaded since the word `eager` will be treated as a part of the tab name

:::

::::

Demo 3

:::: tabs tab-position:left

::: tab A

content 1

:::

::: tab B eager

eagerly loaded content

:::

::::