Skip to content

Tab

A simple vue tab component.

Demo

Slot Based

Overview panel content.


Disabled Tabs

Overview panel content.


Vertical Slot Based

Start with basics to understand the slot contract.


With Custom Tab Markup

Messages

Unread and recent conversations are shown in this panel.

Active tab id: messages

Install

bash
npm i @vuesimple/vs-tab

Usage

html
<template>
  <vs-tab v-model="selectedTab" :disabled-items="['usage']">
    <template #tab-overview>Overview</template>
    <template #tab-usage>Usage</template>
    <template #tab-activity>Activity</template>

    <template #panel-overview>
      <p>Overview panel content.</p>
    </template>
    <template #panel-usage>
      <p>Define content per tab with <code>#panel-*</code> slots.</p>
    </template>
    <template #panel-activity>
      <p>Great DX when panel content is mostly custom markup.</p>
    </template>
  </vs-tab>
</template>

<script>
  import VsTab from '@vuesimple/vs-tab';

  export default {
    components: {
      VsTab,
    },
    data() {
      return {
        selectedTab: 'overview',
      };
    },
  };
</script>

CDN

html
<script src="https://cdn.jsdelivr.net/npm/@vuesimple/vs-tab@<version>/dist/index.min.js"></script>

TIP

Replace <version> with a version number in the above url.

javascript
// Main/Entry file
app.use(VsTab.plugin);

Props

NameTypeDefaultDescription
model-valueString/Number/Object-Active tab id (supports v-model)
is-verticalBooleanfalseStacks tabs vertically
orientationStringhorizontalOrientation mode (horizontal, vertical)
activationStringautoKeyboard behavior (auto or manual)
aria-labelStringTabAccessible label for tablist
disabled-itemsArray[]Tab ids that should be disabled (['usage'])

Events

NameDescription
update:modelValueEmitted when selected tab changes
changeEmitted as (selectedItem, selectedTab)

Slots

NameDescription
tab-<item>Named tab slot for a specific tab (tab-overview)
panel-<item>Named panel slot for a specific panel (panel-overview)

VsTab is slot-based only and derives tab ids from tab-* / panel-* slot names.