Skip to content

TabView-Demo


Data


  1. items
javascript
items = [
    {
        key: 'explorer',
        name: 'Explorer',
        title: 'Explorer',
        show: true,
        disabled: false,
        draggable: true,
        closable: true,
        modified: false,
        icon: 'FolderHorizontal',
        img: ''
    }
]

modified also supports a function and is resolved with valueTrigger, so you can compute the unsaved state dynamically per tab item.

Properties


PropertyTypeRequiredDefaultDescription
modelValueobjectNonullCurrently selected tab item.
itemsarrayNo[{ name: 'Tab' }]Tab item list. Each item usually uses key, name or title, plus optional icon, img, image, or src.
itemWidthnumber / stringNo180Unified width for every tab.
itemHeightnumber / stringNo38Tab height.
paddingstringNo''Outer padding of the component.
borderRadiusnumber / stringNo8Outer border radius.
foregroundstringNo''Text and icon color of normal tabs.
choosenForegroundstringNo''Text and icon color of the selected tab.
chooseBackgroundstringNo''Background of the selected tab.
backgroundstringNo''Background of the whole TabView.
normalBackgroundstringNo''Background of a tab in its normal state.
hoverBackgroundstringNo''Background of a tab while hovering.
activeBackgroundstringNo''Background of a tab while active.
fontSizenumber / stringNo13Font size of the tab title.
imgBorderRadiusnumber / stringNo4Border radius for tab images.
draggablebooleanNotrueWhether tabs can be reordered by drag and drop.
closablebooleanNotrueWhether tabs show a close button by default. Items can set closable: false to opt out.
listPaddingstringNo''Padding applied to the internal tab list container.
itemBorderRadiusnumber / stringNo8Border radius of each tab item.
showAddButtonbooleanNofalseWhether to show the add button on the right side.
addButtonIconstringNo'Add'Fluent icon name used by the add button.
addButtonBackgroundstringNo''Background of the add button.
addButtonForegroundstringNo''Foreground color of the add button.
closeButtonIconstringNo'ChromeClose'Fluent icon name used by the close button.
closeIconSizenumber / stringNo10Icon size of the close button.
modifiedButtonIconstringNo'CircleFill'Fluent icon name shown for modified tabs before hover.
modifiedIconSizenumber / stringNo8Icon size of the modified indicator.
beforeClosefunctionNo() => trueInterceptor called before a tab is closed. Receives { event, item, items, index }. Closing continues only when it returns true.
closeButtonForegroundstringNo''Foreground color of the close button.
styleModestringNo'borderless'Visual style of the tabs. Currently supports borderless and rounded.
overflowModestringNo'scroll'Overflow behavior for many tabs. Use scroll to keep tab width and enable horizontal scrolling, or shrink to compress tabs into one row.
themestringNo'global'Theme style. Supports global, light, dark, system, and custom.
disabledbooleanNofalseDisable the whole component.
langstringNo'global'Language option inherited from common props.

Slots


  1. item

Customizes the entire tab item content. When this slot is used, the default icon + title layout is replaced.

  • item: current tab item
  • index: current tab index
  • eqal: returns whether the tab is selected
  • valueTrigger: resolves direct values or getter functions on the item
vue
<template v-slot:item="{ item, index, eqal, valueTrigger }">
    <div
        style="display: flex; align-items: center; gap: 8px;"
    >
        <i
            class="ms-Icon"
            :class="`ms-Icon--${valueTrigger(item.icon)}`"
        ></i>
        <b>{{ valueTrigger(item.name) }}</b>
        <span v-if="eqal(item)">Current</span>
    </div>
</template>
  1. icon

Customizes only the icon area inside the default tab item layout. If item is already used, this slot will not take effect.

  • item: current tab item
  • index: current tab index
  • eqal: returns whether the tab is selected
  • valueTrigger: resolves direct values or getter functions on the item
vue
<template v-slot:icon="{ item, valueTrigger }">
    <i
        class="ms-Icon"
        :class="`ms-Icon--${valueTrigger(item.icon)}`"
        style="font-size: 18px;"
    ></i>
</template>
  1. close-button

Customizes the close button content for closable tabs.

  • item: current tab item
  • index: current tab index
  • modified: whether the current tab item is in modified state
vue
<template v-slot:close-button="{ item, modified }">
    <i
        class="ms-Icon"
        :class="modified ? 'ms-Icon--CircleFill' : 'ms-Icon--Cancel'"
        :title="item.name"
    ></i>
</template>
  1. add-button

Customizes the add button content shown on the right side when showAddButton is true.

vue
<template v-slot:add-button>
    <i class="ms-Icon ms-Icon--Add"></i>
</template>

Emits


EventArgumentsDescription
update:modelValueobjectTriggered when the selected tab changes.
update:itemsarrayTriggered after close or drag reordering updates the tab list.
changeobjectTriggered when the selected tab changes.
clickobjectTriggered when a tab is clicked. Returns the clicked tab item.
addeventTriggered when the add button is clicked.
closeobjectTriggered when a tab is closed. Returns event, item, items, and index.
reorderobjectTriggered after drag reordering. Returns item, items, from, and to.

MIT Licensed