Skip to content

Tabs

The Tabs component is a responsive horizontal navigation bar that allows the user to easily switch between content. Tab panelsare a set of individual content sections, where only one content panel can be displayed at a time. Each tab panel has an associated tab element that, when activated, displays the panel. The list of tab elements is arranged along one edge of the currently displayed panel, the top edge. The component implements the W3C ARIA APG Tabs Pattern.

Examples

Base

Each item component can have a value prop. The active tab is represented by the value of the item as the modelValue prop of the tabs component.

Types

The tabs header can be displayed in different styles using the type prop.

Position

The tabs header can be positioned by the position prop.

Expanded

When the expanded prop is set, the tabs header will be occupy the full with it can have.

Sizes

The component can be displayed in different sizes using the size prop.

Vertical

Adding the vertical prop displays the component vertically instead of horizontally.

Custom header

The individual tab label can be customised using the header slot.

Long header

The multiple prop allows to break the tab header to be broken into multiple lines if there are too many tabs for one line.

Tabs component

Responsive horizontal navigation tabs, switch between contents with ease.

html
<o-tabs></o-tabs>

Props

Prop nameDescriptionTypeValuesDefault
activateOnFocusSet the tab active on navigation focusboolean-false
animateInitiallyApply animation on the initial renderboolean-
From config:
tabs: {
  animateInitially: false
}
animatedTab will have an animationboolean-
From config:
tabs: {
  animated: true
}
animationTransition animation name[string, string, string, string] | [string, string][next, prev], [right, left, down, up]
From config:
tabs: {
  animation: [ "slide-next", "slide-prev", "slide-down", "slide-up",]
}
ariaLabelAccessibility aria-label to be passed to the tablist wrapper elementstring-
From config:
tabs: {
  ariaLabel: undefined
}
expandedTabs will be expanded (full-width)boolean-false
v-modelThe selected item value, use v-model to make it two-way bindingstring|number|object-
multilineShow tab items multiline when there is no spaceboolean-false
optionsTabs options, unnecessary when default slot is usedOptionsProp<unknown>-
overrideOverride existing theme classes completelyboolean-
positionPosition of the tabs"centered" | "left" | "right"left, centered, right
sizeTab sizestringsmall, medium, large
From config:
tabs: {
  size: undefined
}
tagTablist tag nameDynamicComponent-
From config:
tabs: {
  tag: "div"
}
typeTab typestringdefault, boxed, toggle, pills
From config:
tabs: {
  type: "default"
}
variantColor of the controlstringprimary, info, success, warning, danger, and any other custom color
From config:
tabs: {
  variant: undefined
}
verticalShow tab in vertical layoutboolean-
From config:
tabs: {
  vertical: false
}

Events

Event namePropertiesDescription
update:model-valuevalue T - updated modelValue propmodelValue prop two-way binding
changevalue T - new tab value
value T - old tab value
on tab change event

Slots

NameDescriptionBindings
beforeAdditional slot before tabs
afterAdditional slot after tabs
defaultPlace tab items here

TabItem component

An tab item used by the tabs component.

html
<o-tab-item></o-tab-item>

Props

Prop nameDescriptionTypeValuesDefault
componentComponent to be injected.Component-
contentText content, unnecessary when default slot is usedstring-
disabledItem will be disabledboolean-false
eventsEvents to be binded to the injected component{}-
iconIcon on the leftstring-
From config:
tabs: {
  icon: undefined
}
iconPackIcon packstring-
From config:
tabs: {
  iconPack: undefined
}
labelItem labelstring-
overrideOverride existing theme classes completelyboolean-
propsProps to be binded to the injected componentany-
tagTabs item tag nameDynamicComponent-
From config:
tabs: {
  itemTag: "button"
}
valueItem value (it will be used as v-model of wrapper component) - default is an uuidstring|number|object-
visibleShow/hide itemboolean-true

Events

Event namePropertiesDescription
activateon tab item activate event
deactivateon tab item deactivate event

Slots

NameDescriptionBindings
defaultOverride tab panel contentactive boolean - if item is shown
headerOverride tab header labelactive boolean - if item is shown

Class Inspector

Classes applied to the element:
Class propDescriptionPropsSuffixes
rootClassClass of the root element.
positionClassClass of the root element with position.positionbottom
left
right
sizeClassClass of the root element with size.sizesmall
medium
large
typeClassClass of the root element with type.typedefault
boxed
toggle
pills
expandedClassClass of the root element when expanded.expanded
verticalClassClass of the root element when vertical.vertical
multilineClassClass of the root element when multilined.multiline
listClassClass of the list container element.
contentClassClass of the panel container element.
transitioningClassClass of the panel container element when transitioning.
tabClassClass of the tab item element.
tabActiveClassClass of the tab item element when active.
tabPreviousClassClass of the tab item element before the active one.
tabNextClassClass of the tab item element after the active one.
tabDisabledClassClass of the tab item element when disabled.disabled
tabIconClassClass of the tab item icon element.icon
tabLabelClassClass of the tab item label element.label
tabPanelClassClass of the tab panel element.

Sass variables

Current theme ➜ Oruga

SASS VariableDefault
$tabs-disabled-opacityvar(--#{$prefix}base-disabled-opacity)
$tabs-font-sizevar(--#{$prefix}base-font-size)
$tabs-icon-margin0 0.5em 0 0
$tabs-content-padding1rem
$tabs-margin-bottom1.5rem
$tabs-border-bottom-colorvar(--#{$prefix}grey-lighter)
$tabs-border-bottom-stylesolid
$tabs-border-bottom-width1px
$tabs-tab-colorhsl(0, 0%, 29%)
$tabs-tab-active-border-bottom-colorvar(--#{$prefix}primary)
$tabs-tab-active-colorvar(--#{$prefix}primary)
$tabs-tab-padding0.5em 1em
$tabs-boxed-tab-radiusvar(--#{$prefix}base-border-radius)
$tabs-boxed-tab-hover-background-colorhsl(0, 0%, 96%)
$tabs-boxed-tab-hover-border-bottom-colorhsl(0, 0%, 86%)
$tabs-boxed-tab-active-background-colorhsl(0, 0%, 100%)
$tabs-boxed-tab-active-border-colorhsl(0, 0%, 86%)
$tabs-boxed-tab-active-border-bottom-colortransparent
$tabs-toggle-tab-border-colorhsl(0, 0%, 86%)
$tabs-toggle-tab-border-stylesolid
$tabs-toggle-tab-border-width1px
$tabs-toggle-tab-hover-background-colorhsl(0, 0%, 96%)
$tabs-toggle-tab-hover-border-colorhsl(0, 0%, 71%)
$tabs-toggle-tab-active-background-colorvar(--#{$prefix}primary)
$tabs-toggle-tab-active-border-colorvar(--#{$prefix}primary)
$tabs-toggle-tab-active-colorvar(--#{$prefix}primary-invert)

See ➜ 📄 Full scss file

Current theme ➜ Bulma

SASS VariableDefault
$tabs-focused-outlinenone
$tabs-link-focus-border-bottom-colorcss.getVar( "tabs-link-hover-border-bottom-color")
$tabs-link-focus-active-border-bottom-colorcss.getVar( "tabs-link-active-border-bottom-color")
$tabs-boxed-link-focus-active-background-colorcss.getVar( "tabs-boxed-link-active-background-color")
$tabs-boxed-link-focus-background-colorcss.getVar( "tabs-boxed-link-hover-background-color")
$tabs-boxed-link-focus-active-border-bottom-colorcss.getVar( "tabs-boxed-link-active-border-bottom-color")
$tabs-boxed-link-focus-border-bottom-colorcss.getVar( "tabs-boxed-link-hover-border-bottom-color")
$tabs-toggle-link-focus-active-background-colorcss.getVar( "tabs-toggle-link-active-background-color")
$tabs-toggle-link-focus-background-colorcss.getVar( "tabs-toggle-link-hover-background-color")
$tabs-toggle-link-focus-active-border-colorcss.getVar( "tabs-toggle-link-active-border-color")
$tabs-toggle-link-focus-border-colorcss.getVar( "tabs-toggle-link-hover-border-color")

See ➜ 📄 Full scss file

Current theme ➜ Bootstrap

SASS VariableDefault
$nav-tabs-colorvar(--#{$prefix}body-color)
$nav-tabs-spacer$spacer
$nav-tabs-disabled-opacity0.5
$nav-underline-link-active-bg$nav-tabs-link-active-bg
$nav-underline-link-active-border-colorcurrentcolor

See ➜ 📄 Full scss file

Released under the MIT License.