Skip to content

Tabs

A neo-brutalist style tab navigation component built on top of reka-ui's Tabs primitive. Supports horizontal/vertical layouts, controlled mode, and multiple active state color variants.

Demo

Preview

水平布局(默认)

在此修改您的账户信息。完成后请点击保存。

垂直布局

通用设置选项,包括语言、主题等基础配置。

数据驱动模式(tabs prop)

概览

Installation

pnpm dlx brutx-vue@latest add tabs

Usage

vue
<script setup>
import { Tabs, TabsList, TabsTrigger, TabsContent } from 'brutx-ui-vue/tabs'
</script>

<template>
    <Tabs default-value="account">
        <TabsList>
            <TabsTrigger value="account">Account</TabsTrigger>
            <TabsTrigger value="password">Password</TabsTrigger>
        </TabsList>
        <TabsContent value="account">
            <p class="text-sm">Manage your account settings.</p>
        </TabsContent>
        <TabsContent value="password">
            <p class="text-sm">Change your password here.</p>
        </TabsContent>
    </Tabs>
</template>

Vertical Layout

Set the orientation prop on Tabs to vertical for a vertical layout. In vertical mode, TabsList automatically switches to a vertical arrangement (flex-col), making it suitable for sidebar navigation and similar scenarios.

The orientation prop is passed to child components via dependency injection, so TabsList automatically adapts to the direction without needing to be set individually. If you need to override the direction on a single TabsList, you can set its orientation prop directly.

vue
<script setup>
import { Tabs, TabsList, TabsTrigger, TabsContent } from 'brutx-ui-vue/tabs'
</script>

<template>
    <Tabs default-value="general" orientation="vertical" class="flex gap-4">
        <TabsList>
            <TabsTrigger value="general">General</TabsTrigger>
            <TabsTrigger value="security">Security</TabsTrigger>
            <TabsTrigger value="notifications">Notifications</TabsTrigger>
        </TabsList>
        <TabsContent value="general">
            <p class="text-sm">General settings options.</p>
        </TabsContent>
        <TabsContent value="security">
            <p class="text-sm">Security settings options.</p>
        </TabsContent>
        <TabsContent value="notifications">
            <p class="text-sm">Notification settings options.</p>
        </TabsContent>
    </Tabs>
</template>

Controlled Mode

Use v-model for controlled tab switching:

vue
<script setup>
import { ref } from 'vue'
import { Tabs, TabsList, TabsTrigger, TabsContent } from 'brutx-ui-vue/tabs'

const currentTab = ref('account')
</script>

<template>
    <Tabs v-model="currentTab">
        <TabsList>
            <TabsTrigger value="account">Account</TabsTrigger>
            <TabsTrigger value="password">Password</TabsTrigger>
        </TabsList>
        <TabsContent value="account">
            <p class="text-sm">Manage your account settings.</p>
        </TabsContent>
        <TabsContent value="password">
            <p class="text-sm">Change your password here.</p>
        </TabsContent>
    </Tabs>
</template>

Variants

TabsTrigger supports the following active state color variants:

VariantDescription
defaultDefault active state style
primaryPrimary (coral) background
secondarySecondary background
successSuccess (green) background
vue
<template>
    <TabsTrigger value="tab" variant="primary">Primary variant</TabsTrigger>
</template>

Sizes

TabsList supports the following container sizes:

SizeDescription
smSmall
defaultDefault
lgLarge

Sub-components

ComponentDescription
TabsRoot component (wraps reka-ui's TabsRoot)
TabsListTab trigger container
TabsTriggerClickable tab button
TabsContentContent panel for each tab

Exported Types

Import from the brutx-ui-vue/tabs sub-path:

ts
import {
    Tabs,
    TabsRoot, // reka-ui raw component
    TabsList,
    TabsTrigger,
    TabsContent,
    tabsListVariants,
    tabsTriggerVariants,
    tabsContentVariants,
} from 'brutx-ui-vue/tabs'

Composables

The component exports the following variant utility functions for custom style extensions:

ts
import {
    tabsListVariants,
    tabsTriggerVariants,
    tabsContentVariants,
} from 'brutx-ui-vue/tabs'
FunctionVariant ParametersDescription
tabsListVariantssize: 'sm' | 'default' | 'lg', orientation: 'horizontal' | 'vertical'Container style variants
tabsTriggerVariantsvariant: 'default' | 'primary' | 'secondary' | 'success'Trigger style variants
tabsContentVariantsContent panel base style

Props

Tabs

PropTypeDefaultDescription
modelValuestringValue of the currently active tab (controlled mode)
orientation'horizontal' | 'vertical''horizontal'Tab arrangement direction
classstringCustom CSS class name

TabsList

PropTypeDefaultDescription
size'sm' | 'default' | 'lg''default'Container size
orientation'horizontal' | 'vertical'Inherited from Tabs, defaults to 'horizontal'Arrangement direction, can override parent setting
classstringCustom CSS class name

TabsTrigger

PropTypeDefaultDescription
valuestring— (required)Unique identifier for the tab
disabledbooleanfalseWhether the tab is disabled
variant'default' | 'primary' | 'secondary' | 'success''default'Active state color variant
classstringCustom CSS class name

TabsContent

PropTypeDefaultDescription
valuestring— (required)Corresponding tab value
classstringCustom CSS class name

Events

EventPayloadDescription
update:modelValuestringTriggered when the active tab changes

Accessibility

  • Keyboard: Arrow keys navigate between tab triggers
  • ARIA Attributes: Tab content is associated with its trigger via ARIA attributes; the active tab has aria-selected="true"

Brute force builds.