nb-tabs

This is a tabs component for Vue.js 3+.

Loading component...

Installation

Yarn
yarn add @vlalg-nimbus/nb-navigation
NPM
npm install @vlalg-nimbus/nb-navigation

Usage

Vue 3
import { createApp } from 'vue'
import App from './App.vue'

import NbNavigationComponents from '@vlalg-nimbus/nb-navigation'
import "@vlalg-nimbus/nb-navigation/dist/style.css";

const app = createApp(App)
app.use(NbNavigationComponents)
app.mount('#app')
Nuxt 3
import NbNavigationComponents from '@vlalg-nimbus/nb-navigation'
import "@vlalg-nimbus/nb-navigation/dist/style.css";

export default defineNuxtPlugin(context => {
  context.vueApp.use(NbNavigationComponents)
})

To use, simply call the component, in this case it will be NbTabs or nb-tabs.

Mode 1
<template>
  <NbTabs
    nb-id="tabs-1"
    :tabs="tabs"
    :active-tab="0"
    :disabled-tabs="[2]"
    tab-model="one"
  />
</template>
Mode 2
<template>
  <nb-tabs
    nb-id="tabs-1"
    :tabs="tabs"
    :active-tab="0"
  />
</template>

Preview & Playground

Select the component you want to edit/test

Loading Sandbox...

Props

Items with an (*) mean they are required

nameValue typeDefaultDescription
nbId (*)StringSets the id attribute to differentiate from other components
tabs (*)ArrayList of tab items. Each item must include key and label
activeTab (*)Number0Active tab index (0-based)
disabledTabsArray[]Disabled tabs list (indexes or keys)
tabIndexNumber0Keyboard tab index applied to each tab item
hasTabIndexEnterBooleantrueEnables tab activation with Enter key
hasTabIndexSpaceBooleantrueEnables tab activation with Space key
ariaLabelString'Tab'aria-label on the navigation wrapper (override for your app)
ariaAttrsObject{}Additional aria attributes (auto-prefixed with aria-)
tabModelString'one'Tabs model. Accepts one only in this version
inputStyleString'background'Visual style. Accepts background, line, border
themeString'light'Component theme. Accepts light and dark
disabledBooleanfalseDisables full component interaction
hasBorderRadiusBooleanfalseEnables border radius in non-line styles
borderRadiusNumber0.375Border radius in rem
gapNumber24Gap between tabs in pixels
indicatorWidthNumber3Indicator thickness in pixels
barPaddingLeftNumber0Left padding (px) applied to the tabs bar/header
isScrollClassBooleanfalseEnables horizontal scroll behavior on tabs header
scrollClassString''Optional custom CSS class applied to header when isScrollClass is enabled
paddingXNumber0.2Horizontal tab padding in rem
paddingYNumber0.2Vertical tab padding in rem
fontFamilyString'Lato', sans-serifFont family
fontSizeString'1.6em'Base font size
fontWeightNumber400Base font weight
fontWeightActiveNumber400Active tab font weight
opacityDisabledNumber0.2Disabled state opacity

Theme Colors (Light)

nameValue typeDefaultDescription
lightBgColorString#000000Bar / indicator background (inputStyle background)
lightBorderColorString#eaeaeaBottom border / line (line style header line)
lightTabBorderColorString#000000Tab indicator edge (border style)
lightTextColorString#333333Inactive tab label color
lightTextColorActiveString#ffffffActive tab label color

Theme Colors (Dark)

nameValue typeDefaultDescription
darkBgColorString#353734Background color in dark theme
darkBorderColorString#5f5f5fHeader/border color in dark theme (aligned with NbSegmentedButton)
darkTabBorderColorString#353734Border color for tab indicator (border style)
darkTextColorString#c8c8c8Text color in dark theme
darkTextColorActiveString#ebebebActive text color in dark theme
darkDisabledBorderColorStringrgba(95, 95, 95, 0.45)Disabled border color in dark theme

Events

nameReturn typeDescription
changed{ index: Number, key: String }Fired when active tab changes

Slots

Per-tab content overrides the default {{ tab.label }}.

nameScopeDescription
tab-{index}{ option, index, options }option is the tab object (key, label); options is the full tabs array

Notes

  • In the current implementation, NbTabs renders the tab header and indicator only.
  • The content rendering flow is external by design: use your own v-if rendering and react to the changed event (index/key) to display the active panel.
  • When isScrollClass is true, the tabs header supports horizontal drag-to-scroll with mouse.