Skip to content

Rolling Tab Navigation

Star
👑Pioneer

RollingNavTabs is a rolling navigation component designed to handle variable-length tab lists. It is also built upon the TuiRolling engine, inheriting smooth inertial scrolling and dynamic blur characteristics.

Unlike icon navigation, RollingNavTabs is specifically designed for Tabs scenarios. It supports inserting fixed operation areas (such as "Add Button" or "Menu Button") at the head and tail of the scrolling area. This makes it highly suitable for multi-document editors, tab navigation in administrative back-end systems, and similar use cases.

Core Features

  • Powered by TuiRolling: Offers extreme scrolling performance and supports seamless scrolling for a massive number of tabs.
  • Head and Tail Slot System: Provides prefix and suffix slots, allowing fixed elements (such as settings icons or collapse menus) to reside at the "front" and "rear" of the scrolling area.
  • Flexible Control Bar: The pagination controller can be configured in the head (prefix) or tail (suffix), and supports reversing the sequence with slot content.
  • Dual-Layout: Supports Horizontal and Vertical modes.
  • Rich Interaction: Supports tab closing, locking, and disabled states, as well as drag-scrolling.

Basic Usage

Horizontal Mode

The most common form of tab navigation. Use TuiRollingNavTabs to wrap TuiRollingNavTab child components.

html
<script setup>
import { ref } from 'vue';

const activeTab = ref('tab1');
const tabs = [
  { label: 'Dashboard', value: 'tab1', icon: 'ti-home', locked: true }, // Locked and cannot be closed
  { label: 'Settings', value: 'tab2', icon: 'ti-settings' },
  { label: 'Profile', value: 'tab3' },
];

const handleRemove = (index) => {
  tabs.splice(index, 1);
};
</script>

<template>
  <TuiRollingNavTabs 
    v-model="activeTab" 
    direction="h"
    closeable
  >
    <TuiRollingNavTab 
      v-for="(item, index) in tabs" 
      :key="item.value"
      :index="index"
      :value="item.value" 
      :label="item.label" 
      :icon="item.icon"
      :locked="item.locked"
      @remove="handleRemove(index)"
    />
  </TuiRollingNavTabs>
</template>

Vertical Mode

Set direction="v" to switch to a sidebar tab mode. Often used for side toolbars or vertical menus.

html
<template>
  <div style="height: 400px; width: 160px">
    <TuiRollingNavTabs 
      v-model="activeTab" 
      direction="v"
      :itemApproxHeight="40"
    >
      <TuiRollingNavTab 
        v-for="(item, index) in tabs" 
        :key="item.value"
        v-bind="item" 
        :index="index"
      />
    </TuiRollingNavTabs>
  </div>
</template>

Layout and Slots

The power of RollingNavTabs lies in its flexible area division:

  • Prefix Slot
  • Controller
  • Scrolling Viewport
  • Controller
  • Suffix Slot

Injecting Fixed Content

Fixed operation buttons can be added to both ends of the scrolling area through the #prefix and #suffix slots.

html
<TuiRollingNavTabs>
  <TuiRollingNavTab ... />

  <template #prefix>
    <i class="tui-icon ti-settings"></i>
  </template>

  <template #suffix>
    <i class="tui-icon ti-plus"></i>
  </template>
</TuiRollingNavTabs>

Control Bar Position and Reversal

  • controlPosition: Determines whether the pagination controller (< > arrows) is displayed at the head (prefix) or tail (suffix).
  • prefixReverse / suffixReverse: Determines the arrangement order of the controller and slot content.
  • Default: [Slot Content] [Controller] ...
  • Reversed: [Controller] [Slot Content] ...
html
<template>
  <TuiRollingNavTabs 
    controlPosition="prefix" 
    prefixReverse
  >
    <template #prefix><span>Logo</span></template>
    </TuiRollingNavTabs>
</template>

API Reference

TuiRollingNavTabs Props

PropertyTypeDefaultDescription
modelValueString/Number-The currently active Tab value.
directionString'h'Rolling direction. Options: 'h', 'v'.
itemApproxWidthNumber140(Horizontal mode) Approximate width of an Item, used for virtual scrolling calculations.
itemApproxHeightNumber40(Vertical mode) Approximate height of an Item.
controlPositionString-Control bar position. Options: 'prefix' (Head), 'suffix' (Tail).
prefixReverseBooleanfalseWhether to reverse the order of the prefix area (slot and controller).
suffixReverseBooleanfalseWhether to reverse the order of the suffix area (slot and controller).
closeableBooleanfalseWhether to display a close button.
motionBlurBooleantrueWhether to enable rolling dynamic blur.
resizeObserverString'global'Size monitoring strategy: self, global, none.
durationNumber-Duration of the rolling animation.

TuiRollingNavTab Props

PropertyTypeDefaultDescription
valueString/Number-Unique identifier value of the Tab.
labelString-Display text.
iconString-Icon class name.
indexNumber-Required. Index value used to calculate scrolling position.
disabledBooleanfalseWhether it is disabled.
lockedBooleanfalseWhether it is locked (cannot be closed even if closeable is enabled).

Emits

Event NameDescriptionCallback Parameters
update:modelValueTriggered when the selected value changes.(value)
changeTriggered when the selected item changes.(value, index)
startTriggered when scrolling starts.-
rollingTriggered continuously during the scrolling process.(offset)

Slots

Slot NameDescription
defaultPlace the TuiRollingNavTab list here.
prefixSlot for fixed content at the head.
suffixSlot for fixed content at the tail.

Released under the MIT License.