Usage
Use the Tabs component to display a list of items in a tabs.
Items
Use the items prop as an array of objects with the following properties:
label?: stringicon?: IconComponentavatar?: AvatarPropsbadge?: string | number | BadgePropscontent?: stringvalue?: string | numberdisabled?: booleanslot?: stringclass?: anyb24ui?: { trigger?: ClassNameValue, leadingIcon?: ClassNameValue, leadingAvatar?: ClassNameValue, leadingAvatarSize?: ClassNameValue, label?: ClassNameValue, trailingBadge?: ClassNameValue, trailingBadgeSize?: ClassNameValue, content?: ClassNameValue }
{
"wait": "Loading client-side content..."
}Content
Set the content prop to false to turn the Tabs into a toggle-only control without displaying any content. Defaults to true.
{
"wait": "Loading client-side content..."
}Unmount
Use the unmount-on-hide prop to prevent the content from being unmounted when the Tabs is collapsed. Defaults to true.
{
"wait": "Loading client-side content..."
}Size
Use the size prop to change the size of the Tabs.
{
"wait": "Loading client-side content..."
}Orientation
Use the orientation prop to change the orientation of the Tabs. Defaults to horizontal.
{
"wait": "Loading client-side content..."
}Examples
Control active item
You can control the active item by using the default-value prop or the v-model directive with the value of the item. If no value is provided, it defaults to the index as a string.
With content slot
Use the #content slot to customize the content of each item.
This is the Account tab.
With custom slot
Use the slot property to customize a specific item.
You will have access to the following slots:
#{{ item.slot }}
Make changes to your account here. Click save when you're done.
API
Props
Slots
Emits
Expose
When accessing the component via a template ref, you can use the following:
Theme
export default defineAppConfig({
b24ui: {
tabs: {
slots: {
root: 'style-outline-accent-2 flex items-center gap-2',
list: 'relative flex p-1 group',
indicator: 'absolute transition-[translate,width] duration-200',
trigger: 'group relative inline-flex items-center min-w-0 data-[state=inactive]:text-(--ui-color-design-plain-na-content) hover:data-[state=inactive]:not-disabled:text-(--ui-color-design-selection-content) font-(--ui-font-weight-medium) cursor-pointer disabled:cursor-not-allowed disabled:opacity-30 transition-colors rounded-(--ui-border-radius-md)',
leadingIcon: 'shrink-0',
leadingAvatar: 'shrink-0',
leadingAvatarSize: '',
label: '',
trailingBadge: 'shrink-0',
trailingBadgeSize: 'sm',
content: 'focus:outline-none w-full'
},
variants: {
variant: {
link: {
list: 'border-(--ui-color-divider-vibrant-accent-more)',
indicator: 'rounded-(--ui-border-radius-pill)',
trigger: 'focus:outline-none'
}
},
orientation: {
horizontal: {
root: 'flex-col',
list: 'w-full',
indicator: 'left-0 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position)',
trigger: 'justify-center'
},
vertical: {
list: 'flex-col',
indicator: 'top-0 h-(--reka-tabs-indicator-size) translate-y-(--reka-tabs-indicator-position)'
}
},
size: {
xss: {
trigger: 'px-2 py-1 text-(length:--ui-font-size-4xs)/[normal] gap-1',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs'
},
xs: {
trigger: 'px-2 py-1 text-(length:--ui-font-size-xs)/[normal] gap-1',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs'
},
sm: {
trigger: 'px-2.5 py-1.5 text-(length:--ui-font-size-sm)/[normal] gap-1.5',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs'
},
md: {
trigger: 'px-3 py-1.5 text-(length:--ui-font-size-md)/[normal] gap-1.5',
leadingIcon: 'size-5',
leadingAvatarSize: '2xs'
},
lg: {
trigger: 'px-3 py-2 text-(length:--ui-font-size-lg)/[normal] gap-2',
leadingIcon: 'size-5',
leadingAvatarSize: '2xs'
},
xl: {
trigger: 'px-3 py-2 text-(length:--ui-font-size-xl)/[normal] gap-2',
leadingIcon: 'size-6',
leadingAvatarSize: 'xs'
}
}
},
compoundVariants: [
{
orientation: 'horizontal',
variant: 'link',
class: {
list: 'border-b -mb-px',
indicator: '-bottom-px h-px'
}
},
{
orientation: 'vertical',
variant: 'link',
class: {
list: 'border-s -ms-px',
indicator: '-start-px w-px'
}
},
{
variant: 'link',
class: {
indicator: 'bg-(--ui-color-design-selection-content)',
trigger: [
'focus-visible:ring-1 focus-visible:ring-inset',
'data-[state=active]:text-(--b24ui-color)',
'focus-visible:ring-(--ui-color-design-selection-content)'
]
}
}
],
defaultVariants: {
variant: 'link',
size: 'md'
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'
export default defineConfig({
plugins: [
vue(),
bitrix24UIPluginVite({
b24ui: {
tabs: {
slots: {
root: 'style-outline-accent-2 flex items-center gap-2',
list: 'relative flex p-1 group',
indicator: 'absolute transition-[translate,width] duration-200',
trigger: 'group relative inline-flex items-center min-w-0 data-[state=inactive]:text-(--ui-color-design-plain-na-content) hover:data-[state=inactive]:not-disabled:text-(--ui-color-design-selection-content) font-(--ui-font-weight-medium) cursor-pointer disabled:cursor-not-allowed disabled:opacity-30 transition-colors rounded-(--ui-border-radius-md)',
leadingIcon: 'shrink-0',
leadingAvatar: 'shrink-0',
leadingAvatarSize: '',
label: '',
trailingBadge: 'shrink-0',
trailingBadgeSize: 'sm',
content: 'focus:outline-none w-full'
},
variants: {
variant: {
link: {
list: 'border-(--ui-color-divider-vibrant-accent-more)',
indicator: 'rounded-(--ui-border-radius-pill)',
trigger: 'focus:outline-none'
}
},
orientation: {
horizontal: {
root: 'flex-col',
list: 'w-full',
indicator: 'left-0 w-(--reka-tabs-indicator-size) translate-x-(--reka-tabs-indicator-position)',
trigger: 'justify-center'
},
vertical: {
list: 'flex-col',
indicator: 'top-0 h-(--reka-tabs-indicator-size) translate-y-(--reka-tabs-indicator-position)'
}
},
size: {
xss: {
trigger: 'px-2 py-1 text-(length:--ui-font-size-4xs)/[normal] gap-1',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs'
},
xs: {
trigger: 'px-2 py-1 text-(length:--ui-font-size-xs)/[normal] gap-1',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs'
},
sm: {
trigger: 'px-2.5 py-1.5 text-(length:--ui-font-size-sm)/[normal] gap-1.5',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs'
},
md: {
trigger: 'px-3 py-1.5 text-(length:--ui-font-size-md)/[normal] gap-1.5',
leadingIcon: 'size-5',
leadingAvatarSize: '2xs'
},
lg: {
trigger: 'px-3 py-2 text-(length:--ui-font-size-lg)/[normal] gap-2',
leadingIcon: 'size-5',
leadingAvatarSize: '2xs'
},
xl: {
trigger: 'px-3 py-2 text-(length:--ui-font-size-xl)/[normal] gap-2',
leadingIcon: 'size-6',
leadingAvatarSize: 'xs'
}
}
},
compoundVariants: [
{
orientation: 'horizontal',
variant: 'link',
class: {
list: 'border-b -mb-px',
indicator: '-bottom-px h-px'
}
},
{
orientation: 'vertical',
variant: 'link',
class: {
list: 'border-s -ms-px',
indicator: '-start-px w-px'
}
},
{
variant: 'link',
class: {
indicator: 'bg-(--ui-color-design-selection-content)',
trigger: [
'focus-visible:ring-1 focus-visible:ring-inset',
'data-[state=active]:text-(--b24ui-color)',
'focus-visible:ring-(--ui-color-design-selection-content)'
]
}
}
],
defaultVariants: {
variant: 'link',
size: 'md'
}
}
}
})
]
})